From bb158423539b05f958bafdf95f7cfc0f419e07fb Mon Sep 17 00:00:00 2001 From: Steven Wilson Date: Wed, 7 Dec 2022 17:20:25 +0000 Subject: [PATCH] pop from copy --- day05/day05-2.py | 4 +++- day05/day05.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/day05/day05-2.py b/day05/day05-2.py index 149b3da..9de761a 100644 --- a/day05/day05-2.py +++ b/day05/day05-2.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import re +import copy test = (""" [D] [N] [C] @@ -38,7 +39,8 @@ def rearrange_stacks( input ): return stack def read_stacks_top( stacks ): - top = list(map(list.pop, stacks)) + stacks_c = copy.deepcopy(stacks) + top = list(map(list.pop, stacks_c)) print("".join(top)) diff --git a/day05/day05.py b/day05/day05.py index 417b920..90389ed 100644 --- a/day05/day05.py +++ b/day05/day05.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import re +import copy test = (""" [D] [N] [C] @@ -38,7 +39,8 @@ def rearrange_stacks( input ): return stack def read_stacks_top( stacks ): - top = list(map(list.pop, stacks)) + stacks_c = copy.deepcopy(stacks) + top = list(map(list.pop, stacks_c)) print("".join(top))