0

I am doing Day 9 of AOC, but I am seeing something I don't understand in python.

the full code is here: https://github.com/jzoudavy/AOC2020/blob/master/day9.py

the part I am having trouble is this:

print(data)
original = data # here i meant to make a copy of data
preamble = 5
# in this while loop a bunch of stuff was done on data, particularly the pop
while not rulecheck(data[:(preamble+1)]):
    data.pop(0) 

print(data)
print(original) # when I print here I see the change that was done on data reflected here

script output: first line is the original input data, 2nd line is the data in the while loop when it is finished, 3rd line is the data after we are out of the while loop. Last one is original. I don't know where in my code I could have updated original.

[35, 20, 15, 25, 47, 40, 62, 55, 65, 95, 102, 117, 150, 182, 127, 219, 299, 277, 309, 576]
[95, 102, 117, 150, 182, 127, 219, 299, 277, 309, 576]
[95, 102, 117, 150, 182, 127, 219, 299, 277, 309, 576]
[95, 102, 117, 150, 182, 127, 219, 299, 277, 309, 576]

pycharm debugger confirms this too. enter image description here

D.Zou
  • 761
  • 8
  • 25

0 Answers0