From 6e677b24280f664c68c5ef52498b4cf44f4763c3 Mon Sep 17 00:00:00 2001 From: Dan Katzuv Date: Wed, 14 Dec 2022 00:19:51 +0200 Subject: [PATCH] Add function that returns the tops of stacks after transfers finish --- puzzles/solutions/2022/d05/p1.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/puzzles/solutions/2022/d05/p1.py b/puzzles/solutions/2022/d05/p1.py index b5152b1..54093a7 100644 --- a/puzzles/solutions/2022/d05/p1.py +++ b/puzzles/solutions/2022/d05/p1.py @@ -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__":