aboutsummaryrefslogtreecommitdiff
path: root/2023/04/puzzle-2.py
blob: 8fdf4fde4792e21cbbc9bdcab6e4111df12dfcc9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def main() -> None:
	with open("input", "r") as f:
		lines = f.readlines()
	xs = [1] * len(lines)
	for i, line in enumerate(lines):
		l, r = map(str.split, line.split('|'))
		l = set(filter(str.isdigit, l))
		r = set(filter(str.isdigit, r))
		n = len(l & r)
		for j in range(n):
			xs[i + j + 1] += xs[i]
	print(sum(xs))


if __name__ == "__main__":
	main()