+/AoC

advent of code

git clone https://git.julia.blue/+/AoC

Joseph RyanDay 4d2cfa7f

master
411 B11 linesraw
1nums = lambda l: {int(i) for i in l.split()}
2lines = [map(nums, l.split(":")[-1].split("|")) for l in open("input")]
3score = lambda n: 1 << n - 1 if n > 0 else 0
4matches = [len(winners & yours) for winners, yours in lines]
5print(sum(map(score, matches)))
6
7counts = [1] * len(matches)
8for i in range(len(matches)):
9    for j in range(i + 1, i + 1 + matches[i]):
10        counts[j] += counts[i]
11print(sum(counts))