Finished in 6:14!! This was a easy and fun set of puzzles.

<img src="https://natedileas.files.wordpress.com/2020/12/day6_pithy_screenshot.png" title="Apparently the North Pole is doing a bad job with multilingual support. Also, what kind of customs form depends on other people's answers? PA: "Remember to report any suspicious activity, and collaborate with your seatmates to determine if you are illegal aliens. God Bless America."" alt="Apparently the North Pole is doing a bad job with multilingual support. Also, what kind of customs form depends on other people's answers? PA: "Remember to report any suspicious activity, and collaborate with your seatmates to determine if you are illegal aliens. God Bless America.""/>

Apparently the North Pole is doing a bad job with multilingual support. Also, what kind of customs form depends on other people's answers? PA: "Remember to report any suspicious activity, and collaborate with your seatmates to determine if you are illegal aliens. God Bless America."

This challenge was pretty easy; adding up the length of the union (part 1) and the intersection (part 2) of the various sets of records. I took a minute to refresh my mind on the python set and it’s methods, but after that I was pretty much limited by my reading and typing speed. I think this is the first challenge where my typing speed was actually a significant factor. Looking at the leaderboard, the average speed (of the top 100) for this challenge was about 2 minutes. I think I could probably get up there if I did leetcode or hackerrank obsessively. I’ll probably never invest the effort for that, though.

This is the entire code for this challenge. I could have had less code duplication (and gotten the second part done faster) if I had used an explicit union in part 1. Then, part 2 would have a been a copy-paste and a change of a single function name. If only I had realized that the “any” specification was likely to change to “all” for part 2.

from functools import reduce

if __name__ == '__main__':
    data = open('input6.txt').read()

    groups = data.split('\n\n')

    sumuniq = 0
    for group in groups:
        uniq = set(group.replace('\n', ''))
        sumuniq += len(uniq)

    print(sumuniq)

    sumall = 0
    for group in groups:
        sets = [set(person) for person in group.split('\n')]

        sett = reduce(lambda a,b: a.intersection(b), sets)
        sumall += len(sett)

    print(sumall)</pre>