with open("data.dat", 'r') as file: # Read all lines from the file lines = file.readlines()
count = 0
for line in lines: # Strip whitespace from the line and check if it's not empty if line.strip(): # Count the occurrences of '0' and '1' in the line count_0 = line.count('0') count_1 = line.count('1')
# Check if the count of 0's is a multiple of 3 or the count of 1's is a multiple of 2
if count_0 % 3 == 0 or count_1 % 2 == 0:
# Increment the counter if the condition is met
count += 1
print(count)
The flag is just the number. If you were to wrap it in CTFlearn{} it would also work! We have a pretty robust flag checking system!
I know the numbers, but I still don't know how to type the flag
Actually I want to report a bug in the question. In the 10000 lines of 0 and 1, there are: 6660 lines being mixture of 0 and 1 (or only 0 and 1) that fulfill the condition, 3338 lines being mixture of 0 and 1 that DOES NOT fulfill the condition, and 2 lines being "0000000000" (that is 10 zeros). These 2 lines does not fulfill the condition but apparently have to be counted as part of the answer.
These 2 lines probably passed because they do not contain any 1, so if u count the number of ones and mod 0 it u get 0 which still pass in certain codes.
Hopefully this get patched by either removing those 2 lines or changing the answer to 6660 :)
It took me 1 hour to finish it because I thought I needed to separate lines on which the 0 were repeating on each 3rd index and those on which the 1 were repeating on each 2nd index. But then I realized it made no sense because the data returned was gibberish in a sense, and so I thought maybe I just need to count the number of 0s and 1s in each line and based on the modulo operator (%) increment the counter. That worked... Decoding the question alone took 99% of my time.
Lol not sure how to ask that question any easier...
If i read sth. i normally don't think about it like a boolean expression. If i read a or i think about it like "that or that" and not "that or that, but also both". I think you know what i mean.
"I need to know how many lines there are where the number of 0's is a multiple of 3 AND / OR the numbers of 1s is a multiple of 2." Ye but I'm a bit special in that kind of way.
1 month ago
it took me three months to count it all....