Luna Lailatova
2 years ago
1 changed files with 34 additions and 0 deletions
@ -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…
Reference in new issue