if you got a number as an answer then you should directly write it in
Fiz Pro termux PY
filename = '/data/data/com.termux/files/home/storage/downloads/data.dat'
count_valid_lines = 0
with open(filename, 'r') as file: for line in file: # Contar o número de '0' e '1' na linha count_0 = line.count('0') count_1 = line.count('1')
# Verificar se o número de '0' é múltiplo de 3 ou se o número de '1' é múltiplo de 2
if count_0 % 3 == 0 or count_1 % 2 == 0:
count_valid_lines += 1
print(f"Número de linhas válidas no arquivo '{filename}': {count_valid_lines}")
Used python
Used python
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.
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 :)
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.
2 weeks ago
hey I don't know what to write in the flag