1) Simple Programming
Copy the following script and run it with python 2 or 3. All the explanations are on the script.
# initiate the parameters count = 0 file = 'data.dat' with open(file) as f: #Open the file l = f.readlines() #read file by line for line in l: zero = line.count('0') #count number of zero in the line one = line.count('1') #count number of one in the line '''the condition where the number of '0' is divisible by 3 OR the number of '1' is divisible by 2''' if (zero%3 == 0) or (one%2 == 0): count = count + 1 print("Number of lines: " + str(count)) f.close()
That’s all for the simple programming on CTFlearn. The post will be updated once I found another new task. See ya 🙂