from ops import ops from copy import copy with open('input.txt', 'r') as f: raw = f.readlines() samples = [] i = 0 while 1: sample = {} if raw[i] == '\n': break sample['in'] = [int(x) for x in raw[i][9:-2].split(', ')] sample['op'] = [int(x) for x in raw[i + 1].strip().split(' ')] sample['out'] = [int(x) for x in raw[i + 2][9:-2].split(', ')] samples.append(sample) i += 4 print(samples) res = 0 for sample in samples: count = 0 num, a, b, c = sample['op'] for op in ops: try: if sample['out'] == op(copy(sample['in']), a, b, c): count += 1 except: pass if count >= 3: res += 1 # print(sample) print(res)