"""Day 6.""" from collections import Counter def score_part1(group): """Determine score for group in part 1.""" return len(set(group.replace("\n", ""))) def score_part2(group): """Determine score for group in part 2.""" group_size = group.count("\n") + 1 counter = Counter(group.replace("\n", "")) return sum(1 for _, occurences in counter.items() if occurences == group_size) with open("input") as f: groups = f.read().rstrip().split("\n\n") # Part 1 print(sum(map(score_part1, groups))) # Part 2 print(sum(map(score_part2, groups)))