re: AoC Day 2: Inventory Management System VIEW POST

VIEW FULL DISCUSSION
 
from collections import Counter

with open('in.txt') as f:
    counters = list(map(Counter, f))

doubles = sum(2 in counter.values() for counter in counters)
tripples = sum(3 in counter.values() for counter in counters)

print(doubles * tripples)
from itertools import combinations

with open('in.txt') as f:
    ids = f.read().splitlines()

for first, second in combinations(ids, 2):
    if sum(a != b for a, b in zip(first, second)) == 1:
        print(''.join(a for a, b in zip(first, second) if a == b))
code of conduct - report abuse