-
Notifications
You must be signed in to change notification settings - Fork 0
/
01.py
45 lines (38 loc) · 1.11 KB
/
01.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
def one():
biggest_sum = -1
list_of_all_cals = []
with open('input/01.txt', 'r') as f:
lines = f.readlines()
tmp_sum = 0
for line in lines:
if line != "\n":
tmp_sum += int(line)
# print(int(line))
else:
# print(tmp_sum)
if tmp_sum >= biggest_sum:
biggest_sum = tmp_sum
tmp_sum = 0
print(tmp_sum)
print(biggest_sum)
def two():
biggest_sum = -1
list_of_all_cals = []
with open('input/01.txt', 'r') as f:
lines = f.readlines()
tmp_sum = 0
for line in lines:
if line != "\n":
tmp_sum += int(line)
# print(int(line))
else:
list_of_all_cals.append(tmp_sum)
# print(tmp_sum)
if tmp_sum >= biggest_sum:
biggest_sum = tmp_sum
tmp_sum = 0
list_of_all_cals.sort(reverse=True)
end_result = list_of_all_cals[0] + \
list_of_all_cals[1] + list_of_all_cals[2]
print(end_result)
two()