This commit is contained in:
Sebastian Seedorf
2022-12-06 08:41:02 +01:00
parent c3050cb4fe
commit 1b18edd0ba
6 changed files with 570 additions and 2 deletions

11
day05/part1.min.py Normal file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env python3
import re, itertools
lines = (x for x in open("input.txt"))
m=[[e for e in line if e!=' ']for line in zip(*([*line[1::4]]for line in itertools.takewhile(lambda x:'['in x,lines)))]
next(lines)
for line in lines:
a,s,t=map(int,re.search(r"(\d+).+(\d+).+(\d+)",line).groups())
m[t-1],m[s-1]=m[s-1][:a][::-1]+m[t-1],m[s-1][a:]
print(''.join(i[0] for i in m))