Skip to content

Commit dbe8f7e

Browse files
author
Twooey
committed
Moved to using get_data. This requires a token.input file.
1 parent 6d22e38 commit dbe8f7e

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ __pycache__/
55
*.py[cod]
66
*$py.class
77

8+
/token.input
89
*.input
910
# C extensions
1011
*.so
@@ -141,3 +142,4 @@ dmypy.json
141142
cython_debug/
142143

143144
!/.gitignore
145+

day1.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
with open('day1.txt', 'rb') as f:
2-
mylist = set(map(int, f))
3-
templist = mylist.copy()
4-
stop = False
5-
for i in mylist:
6-
for j in templist:
7-
c = 2020 - i - j
8-
if c in mylist:
9-
print(i, j, c, i*j*c)
10-
stop = True
11-
break
12-
if stop == True:
1+
from aocd import get_data
2+
3+
mylist = set(map(int, get_data(open(file='token.input').read(), day=1, year=2020).splitlines()))
4+
5+
templist = mylist.copy()
6+
stop = False
7+
for i in mylist:
8+
for j in templist:
9+
c = 2020 - i - j
10+
if c in mylist:
11+
print(i, j, c, i*j*c)
12+
stop = True
1313
break
14-
else:
15-
templist.pop()
14+
if stop == True:
15+
break
16+
else:
17+
templist.pop()

0 commit comments

Comments
 (0)