2023-12-01 10:23:08 -05:00
|
|
|
#!/usr/bin/env python3
|
2023-12-01 09:29:09 -05:00
|
|
|
import sys
|
2023-12-01 12:01:22 -05:00
|
|
|
|
2023-12-01 09:29:09 -05:00
|
|
|
sum = 0
|
|
|
|
for line in sys.stdin:
|
2023-12-04 13:04:44 -05:00
|
|
|
_, nums = line.split(":")
|
|
|
|
winning, mine = nums.split("|")
|
2023-12-01 12:01:22 -05:00
|
|
|
|
2023-12-04 13:04:44 -05:00
|
|
|
winning = set(winning.split())
|
|
|
|
if len(winning) != len(set(winning)):
|
|
|
|
raise ValueError("Shenannigans!")
|
2023-12-01 12:01:22 -05:00
|
|
|
|
2023-12-04 13:04:44 -05:00
|
|
|
mine = set(mine.split())
|
|
|
|
if len(mine) != len(set(mine)):
|
|
|
|
raise ValueError("Shenannigans! {}".format(mine))
|
2023-12-01 12:01:22 -05:00
|
|
|
|
2023-12-04 13:04:44 -05:00
|
|
|
both = winning.intersection(mine)
|
|
|
|
c = len(both)
|
|
|
|
if c > 0:
|
|
|
|
sum += 2 ** (c - 1)
|
2023-12-01 09:29:09 -05:00
|
|
|
|
|
|
|
print(sum)
|