Initial commit

This commit is contained in:
Geoffrey Frogeye 2024-12-25 12:58:02 +01:00
commit 97a4330bc0
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
110 changed files with 7006 additions and 0 deletions

45
2024/25/one.py Normal file
View file

@ -0,0 +1,45 @@
#!/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)