This commit is contained in:
Sebastian Seedorf
2020-12-30 10:35:08 +01:00
parent 9e79644296
commit 1e78940455
3 changed files with 72 additions and 0 deletions

19
day23/part1.py Normal file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env python3
from functools import reduce
from tqdm import tqdm
num = [list(map(int, (char for char in x.strip()))) for x in open("input.txt")][0]
for _ in tqdm(range(100)):
destination = num[0]
while True:
destination -= 1
if destination == 0:
destination = 9
if not destination in num[1:4]:
break
pos = num.index(destination)
num = num[4:pos+1] + num[1:4] + num[pos+1:] + num[0:1]
pos = num.index(1)
print(reduce(lambda a, b: 10*a+b, num[pos+1:] + num[:pos], 0))