48 lines
1.1 KiB
Python
48 lines
1.1 KiB
Python
|
#!/bin/python3
|
||
|
import sys,re
|
||
|
from pprint import pprint
|
||
|
sys.path.insert(0, '../../')
|
||
|
from fred import list2int
|
||
|
|
||
|
input_f = 'input'
|
||
|
|
||
|
part = 2
|
||
|
#########################################
|
||
|
# #
|
||
|
# Part 1 #
|
||
|
# #
|
||
|
#########################################
|
||
|
|
||
|
if part == 1:
|
||
|
count = 0
|
||
|
with open(input_f) as file:
|
||
|
for line in file:
|
||
|
count += int(line.rstrip())
|
||
|
print(count)
|
||
|
|
||
|
|
||
|
#########################################
|
||
|
# #
|
||
|
# Part 2 #
|
||
|
# #
|
||
|
#########################################
|
||
|
if part == 2:
|
||
|
count = 0
|
||
|
instructions = []
|
||
|
with open(input_f) as file:
|
||
|
for line in file:
|
||
|
instructions.append(int(line.rstrip()))
|
||
|
|
||
|
index = 0
|
||
|
duplicates = []
|
||
|
while True:
|
||
|
count += instructions[index]
|
||
|
index += 1
|
||
|
if count in duplicates:
|
||
|
print(count)
|
||
|
break
|
||
|
duplicates.append(count)
|
||
|
if index == len(instructions):
|
||
|
index = 0
|
||
|
|