aboutsummaryrefslogtreecommitdiff
path: root/2018/01.py
blob: 7a7dc3a9fcaa224772cec6bbccfcfa81f7fbe2ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Day One: Chronal Calibration

file = open("input/01.txt").readlines()

total = 0
for line in file:
	if line != '\n':
		total += int(line)
print(total)

total = {0}
current = 0
while True:
	for line in file:
		if line != '\n':
			current += int(line)
			if current not in total:
				total.add(current)
			else:
				print(current)
				quit()