Day 22
This commit is contained in:
23
day22/part1.py
Normal file
23
day22/part1.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
lines = (x.strip() for x in open("input.txt"))
|
||||
|
||||
stats = [[], []]
|
||||
player2 = False
|
||||
for line in lines:
|
||||
if line.startswith("Player"):
|
||||
continue
|
||||
elif line == "":
|
||||
player2 = True
|
||||
else:
|
||||
stats[1 if player2 else 0].append(int(line))
|
||||
|
||||
|
||||
while all(len(x) > 0 for x in stats):
|
||||
a, b = stats[0].pop(0), stats[1].pop(0)
|
||||
if a > b:
|
||||
stats[0].extend((a, b))
|
||||
else:
|
||||
stats[1].extend((b, a))
|
||||
|
||||
print(list(map(lambda x: sum(i*v for i, v in zip(x, range(len(x), 0, -1))), stats)))
|
||||
Reference in New Issue
Block a user