#!/usr/bin/env python3 import sys input_file = sys.argv[1] with open(input_file) as fd: lines = [line.rstrip() for line in fd.readlines()] lockey = tuple[int, int, int, int, int] locks: list[lockey] = list() keys: list[lockey] = list() i = 0 for line in lines: if not line: i = 0 elif i == 0: is_lock = line == "#####" i = 1 sharps = [0, 0, 0, 0, 0] elif i == 6: if is_lock: locks.append(tuple(sharps)) else: keys.append(tuple(sharps)) else: for j in range(5): if line[j] == "#": sharps[j] += 1 i += 1 print(locks) print(keys) fit = 0 for lock in locks: for key in keys: print(39, lock, key) for i in range(5): if lock[i] + key[i] > 5: break else: fit += 1 print(fit)