Advent of Code 2026 day 1

collections is well worth learning. Slightly surprised that least_common doesn’t exist, though I guess it would be far more rare to need it in the wild.

from collections import Counter

with open("1.txt") as f:
    c = Counter([int(l) for l in f.read().splitlines()])

mult = 1
for x, _ in c.most_common(3):
    mult *= x

print(mult)


mult = 1
for x, _ in c.most_common()[-3:]:
    mult *= x

print(mult)