AoC 2020 D6: Custom Customs
| Problem statement | Source code | Tags: Data structures
← Previous Back to AoC Index Next →
Part 1
Each group's answers is a list of sets. For part 1, if we want the questions anyone answered "yes", that's the union of the sets in each list. Conveniently we can simply concatenate all the strings in the group (removing newlines) and convert that to a set, which automatically removes duplicates.
Part 2
Now we want the questions everyone answered "yes", which is the intersection of the sets in each list. Python's set.intersection method can take multiple arguments, so we can unpack the list of sets with *: