-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday1.py
More file actions
31 lines (26 loc) · 687 Bytes
/
Copy pathday1.py
File metadata and controls
31 lines (26 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
text_file = '''C:/Users/Davinder/PycharmProjects/adventofcode2018/day1input.txt'''
with open(text_file, 'r') as f:
x = [int(line.strip()) for line in f]
# Day 1
# Part 1
def final_freq():
counter = 0
for i in x:
counter += int(i)
print counter
print sum(x)
# Part 2
def duplicate_freq():
running_total = 0
condition = True
a = set()
while condition:
for i in x:
running_total += i
print running_total
if running_total in a:
condition = False
print 'Duplicate is' + ' ' + str(running_total)
break
else:
a.add(running_total)