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))