Skip to content

Commit

Permalink
Add function that returns the tops of stacks after transfers finish
Browse files Browse the repository at this point in the history
  • Loading branch information
katzuv committed Dec 13, 2022
1 parent 2d1208e commit 6e677b2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion puzzles/solutions/2022/d05/p1.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ def execute_transfer_step(stacks: Sequence[Stack], step: Step):


def get_answer(input_text: str):
raise NotImplementedError
"""Return the crates that end up on top of each stack after the rearrangement procedure completes."""
starting_stacks, steps = input_text.split(consts.INPUT_PARTS_SPLITTER)
stacks = input_parsing.get_starting_stacks(starting_stacks)
steps = input_parsing.get_procedure_steps(steps)
for step in steps:
execute_transfer_step(stacks, step)
return "".join(stack.top for stack in stacks)


if __name__ == "__main__":
Expand Down

0 comments on commit 6e677b2

Please sign in to comment.