Skip to content

Commit 27bcfef

Browse files
committed
[2022/5] output both parts
1 parent 563245c commit 27bcfef

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

2022/5/script.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,27 @@ def process_move_multiple(move, stacks):
3939
from_ = int(from_)
4040
to = int(to)
4141
stacks[to].extend(stacks[from_][-num:])
42-
print(from_, stacks[from_][-num:], to)
42+
# print(from_, stacks[from_][-num:], to)
4343
del stacks[from_][-num:]
4444

4545

4646
with open('input') as f:
47-
inputs = (line.rstrip('\n') for line in f)
47+
file = [line.rstrip('\n') for line in f]
48+
inputs = (line for line in file)
49+
50+
stacks = read_stacks(inputs)
51+
# print(stacks)
52+
53+
for move in inputs:
54+
if move.strip():
55+
process_move_single(move, stacks)
56+
# print(stacks)
57+
top_crates = [stacks[crate][-1]
58+
for crate in range(1, 9+1) if stacks[crate]]
59+
# print(top_crates)
60+
print(''.join(top_crates))
61+
62+
inputs = (line for line in file)
4863

4964
stacks = read_stacks(inputs)
5065
# print(stacks)
@@ -55,5 +70,5 @@ def process_move_multiple(move, stacks):
5570
# print(stacks)
5671
top_crates = [stacks[crate][-1]
5772
for crate in range(1, 9+1) if stacks[crate]]
58-
print(top_crates)
73+
# print(top_crates)
5974
print(''.join(top_crates))

2022/5/test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[D]
2+
[N] [C]
3+
[Z] [M] [P]
4+
1 2 3
5+
6+
move 1 from 2 to 1
7+
move 3 from 1 to 3
8+
move 2 from 2 to 1
9+
move 1 from 1 to 2

0 commit comments

Comments
 (0)