1 def move_9000(source, destination, n):
3 destination.append(source.pop())
6 def move_9001(source, destination, n):
7 things_to_move = source[-n:]
8 destination.extend(things_to_move)
15 """Figure out which crate is on top"""
16 with open("5.in") as fh:
22 if line.strip() == "":
25 for stack in range(1, 10):
26 index = 1 + (stack - 1) * 4
28 if char in '1234567890':
32 stacks[stack - 1].append(char)
38 _, n, __, source, ___, destination = line.split(" ")
39 move_9000(stacks[int(source) - 1], stacks[int(destination) - 1], int(n))
46 """Figure out which crate is on top"""
47 with open("5.in") as fh:
53 if line.strip() == "":
56 for stack in range(1, 10):
57 index = 1 + (stack - 1) * 4
59 if char in '1234567890':
63 stacks[stack - 1].append(char)
69 _, n, __, source, ___, destination = line.split(" ")
70 move_9001(stacks[int(source) - 1], stacks[int(destination) - 1], int(n))