2
1
Fork 0
aoc2021/03/solution_1.py

10 lines
357 B
Python
Raw Permalink Normal View History

2021-12-03 16:34:14 +01:00
#!/usr/bin/env python3
from collections import Counter
with open("input.txt", "r") as _input:
most_common_bits = [Counter(col).most_common(2) for col in zip(*[l.rstrip() for l in _input.readlines()][::-1])]
gamma, epsilon = [int("".join(x)[::-1], 2) for x in zip(*[(x[0], y[0]) for x, y in most_common_bits][::-1])]
print("Answer:", gamma * epsilon)