Skip to content

Commit

Permalink
[2022/5] output both parts
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 14, 2024
1 parent 563245c commit 27bcfef
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
21 changes: 18 additions & 3 deletions 2022/5/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,27 @@ def process_move_multiple(move, stacks):
from_ = int(from_)
to = int(to)
stacks[to].extend(stacks[from_][-num:])
print(from_, stacks[from_][-num:], to)
# print(from_, stacks[from_][-num:], to)
del stacks[from_][-num:]


with open('input') as f:
inputs = (line.rstrip('\n') for line in f)
file = [line.rstrip('\n') for line in f]
inputs = (line for line in file)

stacks = read_stacks(inputs)
# print(stacks)

for move in inputs:
if move.strip():
process_move_single(move, stacks)
# print(stacks)
top_crates = [stacks[crate][-1]
for crate in range(1, 9+1) if stacks[crate]]
# print(top_crates)
print(''.join(top_crates))

inputs = (line for line in file)

stacks = read_stacks(inputs)
# print(stacks)
Expand All @@ -55,5 +70,5 @@ def process_move_multiple(move, stacks):
# print(stacks)
top_crates = [stacks[crate][-1]
for crate in range(1, 9+1) if stacks[crate]]
print(top_crates)
# print(top_crates)
print(''.join(top_crates))
9 changes: 9 additions & 0 deletions 2022/5/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[D]
[N] [C]
[Z] [M] [P]
1 2 3

move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2

0 comments on commit 27bcfef

Please sign in to comment.