25
https://adventofcode.com/2024/day/25
Prob1
python
import sys
def schema_to_tuple(schema):
ret = [0, 0, 0, 0, 0]
for i in range(5):
ret[i] = sum([line[i] == '#' for line in schema]) - 1
return tuple(ret)
def schema_match(s1, s2):
for i in range(5):
if s1[i] + s2[i] > 5:
return False
return True
top_schema = []
bottom_schema = []
schema = []
for line in sys.stdin:
line = line.strip()
if line:
schema.append(line)
continue
if schema[0][0] == '#':
top_schema.append(schema_to_tuple(schema))
schema = []
else:
bottom_schema.append(schema_to_tuple(schema))
schema = []
print(len(top_schema), top_schema[0])
print(len(bottom_schema), bottom_schema[0])
ans = 0
for top in top_schema:
for bottom in bottom_schema:
if schema_match(top, bottom):
ans += 1
print(ans)
Prob2
IDK