This commit is contained in:
DUEFON 2022-12-05 06:36:39 +01:00 committed by Eivind Øksnevad
commit 0b729ef76e
1 changed files with 16 additions and 0 deletions

16
five.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
from useful import *
beg, rec = headerfooter(open(0))
begl = beg.split('\n')
a = np.asarray([c for l in begl for c in l]).reshape((len(begl), -1)).T[1::4,::-1]
dock = [None, *[deque(c for c in l if not c in '0123456789 ') for l in a]]
ic(a, dock)
for l in rec.strip().split('\n'):
num, src, dst = (int(n) for n in re.match(r'move (\d+) from (\d+) to (\d+)', l).groups())
ic(num, src, dst)
for i in range(num): # ugh
dock[dst].extend(dock[src].pop())
print(''.join([d.pop() for d in dock[1:]]))