https://np.reddit.com/r/adventofcode/comments/k9eumt/2020_day_6_part_2_python_help_me_be_more_pythonic/gf3swru/

answers = 0
with open('input06.txt') as f:
    for group in f.read().split("\n\n"):
        inter =set.intersection(*[set(l) for l in group.split("\n"])
        answers += len(inter)
print('> part two: {}'.format(answers))

Ok, I got to thinking, and the above feels more elegant to me. I almost started to wander over to map() and reduce() but... eh?

Posted Dec 8, 2020, 11:03 PM UTC

10

No comments yet

Nobody commented on this post, or the comments weren't captured.