parent
50ac55afd1
commit
31e10c67da
1 changed files with 20 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||||||
|
data = open("input.txt", 'r').read() |
||||||
|
|
||||||
|
stacks, instructions = data.split("\n\n") |
||||||
|
stacks = stacks.splitlines() |
||||||
|
instructions = [i.split(" ") for i in instructions.splitlines()] |
||||||
|
s = [] |
||||||
|
|
||||||
|
for i in range(int(stacks[-1][-2])): |
||||||
|
s.append([]) |
||||||
|
for j in range(len(stacks)-1): |
||||||
|
crate = stacks[-j-2][i*4+1] |
||||||
|
if crate != " ": |
||||||
|
s[i].append(crate) |
||||||
|
|
||||||
|
for i in instructions: |
||||||
|
for j in range(int(i[1])): |
||||||
|
s[int(i[5])-1].append(s[int(i[3])-1].pop()) |
||||||
|
|
||||||
|
|
||||||
|
print("".join([t.pop() for t in s])) |
Loading…
Reference in new issue