יום 1 - Chronal Calibration

פתרון לחלק 2 בפייתון:

""" The program find the first sum that appears twice"""

path = r'C:\Users\Champion\PycharmProjects\Advent_of_code\res_freq.txt'


index = 0
lst = []
temp = 0

with open(path, "r") as f_r:
    p = [int(i) for i in f_r]

#p = [1,-2,3,1]
while True:
    temp = temp + p[index % len(p)]
    if temp in lst:break
    lst.append(temp)
    index += 1
print temp