import re def check_divisibility(line): # Sprawdzanie, czy napis jest zapisany dziesiętnie i czy jest podzielny przez 4 decimal_pattern = re.compile(r'^0$|^[1-9][0-9]*$') if decimal_pattern.match(line) and int(line) % 4 == 0: return 'yes' # Sprawdzanie, czy napis jest zapisany szesnastkowo i czy jest podzielny przez 4 hex_pattern = re.compile(r'^0x[1-9A-F]+$|^0x0$') if hex_pattern.match(line) and int(line, 16) % 4 == 0: return 'yes' return 'no' def main(file_path): try: with open(file_path, 'r') as file: for line in file: line = line.rstrip('\n') result = check_divisibility(line) print(result) except FileNotFoundError: print(f'File "{file_path}" not found.') file_path = 'test.in' main(file_path)