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
Great Challenge! solved this using python:
Lines = 0 with open('data.txt', 'r') as file: for line in file: count_zeros = line.count("0") count_ones = line.count("1") if count_ones % 2 == 0 or count_zeros % 3 == 0: Lines += 1 print(Lines)
just need to reformat the file into .txt ( might work with .dat too but didnt try)
would give -10^googleplex if could: this is def not an "ez" programming prob: i.e. rank beginner like moi has no chance (I humbly bow to those that found it ez - u have god-like powers to me). i spent over a week googling and stumbling through error codes. finally read community and found sol'n given by m1tn1ck 3mo ago (keep refreshing cuz sometimes it shows up, sometimes it don't...ctf"learn" idea of a joke?). anyways thank u m1tn1ck for saving me from impending insanity
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 months ago
took 20 sec's with chatgpt