Simple Programming
30 points Easy

Can you help me? I need to know how many lines there are where the number of 0's is a multiple of 3 or the numbers of 1s is a multiple of 2. Please! Here is the file: https://mega.nz/#!7aoVEKhK!BAohJ0tfnP7bISIkbADK3qe1yNEkzjHXLKoJoKmqLys

Flag
Rating 4.41
5
4
3
2
1

Discussion

hey I don't know what to write in the flag

0

if you got a number as an answer then you should directly write it in

0
Protected
0

took 20 sec's with chatgpt

-4
Protected
0

Fiz Pro termux PY

Caminho para o arquivo data.dat no Termux

filename = '/data/data/com.termux/files/home/storage/downloads/data.dat'

Contador para linhas válidas

count_valid_lines = 0

Abrir o arquivo e ler linha por linha

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

Exibir o resultado

print(f"Número de linhas válidas no arquivo '{filename}': {count_valid_lines}")

-2

Fun, I ended up completing this using AWK and creating a one-liner on command line.

0
Protected
0

Used python

3

Used python

0

i solved it, actually turns out i didn't read it carefully at first

0