-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday1.py
47 lines (39 loc) · 801 Bytes
/
day1.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#AOC 2019 Brianna Frye
#Day 1
def parse_to_array(base_file):
data_left = True
output_array = []
try:
file = open(base_file)
while data_left == True:
temp = file.readline()
if temp == '':
data_left = False
break
output_array.append(temp)
file.close()
return output_array
except IOError:
print('File does not exist!')
finally:
print('Parsing complete!')
data = parse_to_array('day1input.txt')
total = 0
temp = 0
for i in data:
temp = int(i) // 3
temp -= 2
total += temp
print(str(total))
total = 0
temp = 0
# PART 2
for i in data:
test = int(i)
while test > 0:
temp = test // 3
temp -= 2
if temp > 0:
total += temp
test = temp
print(total)