Skip to content

Commit a12500f

Browse files
committed
day1
1 parent 69d56b8 commit a12500f

File tree

2 files changed

+1008
-0
lines changed

2 files changed

+1008
-0
lines changed

2018/day1.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import itertools
2+
3+
def readwords():
4+
with open('input/day1.txt') as f:
5+
for line in f.read().splitlines():
6+
yield int(line.strip())
7+
8+
print(sum(readwords()))
9+
10+
11+
last = 0
12+
p = set([last])
13+
for i in itertools.cycle(readwords()):
14+
last += i
15+
if last in p:
16+
print(last)
17+
break
18+
p.add(last)

0 commit comments

Comments
 (0)