Browse Source

finished day20, skipped 19 for now

main
Luna Lailatova 2 years ago
parent
commit
45d899b36b
  1. 34
      day20-2.py

34
day20-2.py

@ -0,0 +1,34 @@
with open('input20.txt','r') as f:
inp = f.read().splitlines(keepends=False)
sequence = []
decryptionKey = 811589153
for i in range(len(inp)):
if int(inp[i]) == 0:
zero = (i, int(inp[i]))
sequence.append((i, int(inp[i]) * decryptionKey))
numbers = sequence.copy()
for number in sequence:
if sequence.count(number) > 1:
print('!')
for i in range(10):
for number in numbers:
index = sequence.index(number)
_number = number[1]
newIndex = index + _number
sequence.pop(index)
newIndex %= len(sequence)
sequence.insert(newIndex, number)
number = sequence.index(zero) + 1000
_sum = 0
for i in range(3):
number %= len(sequence)
#print(sequence[number])
_sum += sequence[number][1]
number += 1000
print(_sum)
Loading…
Cancel
Save