summaryrefslogtreecommitdiffstats
path: root/prog/aoc/23/4/1.py
blob: 2296fb9bada096cac5af55cd7532846dbf36d30f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/python3
s = 0
c = []
t = []
try:
	while True:
		l = input()
		w = set(l.split(":")[1].split(" | ")[0].split(" "))-set([""])
		m = set(l.split(":")[1].split(" | ")[1].split(" "))-set([""])
		c.append(len(m&w))
		t.append(1)
		if len(m&w) > 0:
			s += 2**(len(w & m)-1)
except:
	print(s)
	s2 = 0
	for i in range(len(c)):
		for j in range(c[i]):
			t[1+i+j] += t[i]
		s2 += t[i]
	print(s2)