Skip to content

Commit 2340139

Browse files
author
Zoe Peterson
committed
Day 1 finished, yay
0 parents  commit 2340139

File tree

3 files changed

+988
-0
lines changed

3 files changed

+988
-0
lines changed

day1.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#coding: utf-8
2+
3+
def findDuplicateFrequency(lines):
4+
frequencies_seen = set()
5+
total = 0
6+
#Keep looping through the lines in the file until you find a duplicate frequency
7+
while True:
8+
for line in lines:
9+
total += int(line)
10+
if total in frequencies_seen:
11+
return total
12+
else:
13+
frequencies_seen.add(total)
14+
15+
16+
file_object = open("input_day_1.txt", "r")
17+
lines = file_object.readlines()
18+
print(findDuplicateFrequency(lines))
19+
file_object.close()

0 commit comments

Comments
 (0)