|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
from copy import deepcopy |
|
|
|
|
|
|
|
|
|
|
|
data = open("input.txt", 'r').read() |
|
|
|
data = open("input.txt", 'r').read() |
|
|
|
|
|
|
|
|
|
|
|
stacks, instructions = data.split("\n\n") |
|
|
|
stacks, instructions = data.split("\n\n") |
|
|
@ -12,9 +14,17 @@ for i in range(int(stacks[-1][-2])): |
|
|
|
if crate != " ": |
|
|
|
if crate != " ": |
|
|
|
s[i].append(crate) |
|
|
|
s[i].append(crate) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s2 = deepcopy(s) |
|
|
|
|
|
|
|
|
|
|
|
for i in instructions: |
|
|
|
for i in instructions: |
|
|
|
for j in range(int(i[1])): |
|
|
|
destination = int(i[5])-1 |
|
|
|
s[int(i[5])-1].append(s[int(i[3])-1].pop()) |
|
|
|
origin = int(i[3])-1 |
|
|
|
|
|
|
|
quantity = int(i[1]) |
|
|
|
|
|
|
|
s2[destination] += s2[origin][-quantity:] |
|
|
|
|
|
|
|
for j in range(quantity): |
|
|
|
|
|
|
|
s[destination].append(s[origin].pop()) |
|
|
|
|
|
|
|
s2[origin].pop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("".join([t.pop() for t in s])) |
|
|
|
print("".join([t.pop() for t in s])) |
|
|
|
|
|
|
|
print("".join([t.pop() for t in s2])) |