You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
805 B
34 lines
805 B
2 years ago
|
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)
|