Completed day 1
This commit is contained in:
14
2022/Day-01/day01-1.py
Normal file
14
2022/Day-01/day01-1.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
elves = []
|
||||||
|
|
||||||
|
with open('input.txt', 'r') as inputFile:
|
||||||
|
for line in inputFile:
|
||||||
|
if line == '\n':
|
||||||
|
elves.append(total)
|
||||||
|
total = 0
|
||||||
|
else:
|
||||||
|
total += int(line)
|
||||||
|
|
||||||
|
print(max(elves))
|
19
2022/Day-01/day01-2.py
Normal file
19
2022/Day-01/day01-2.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
total = 0
|
||||||
|
elves = []
|
||||||
|
|
||||||
|
with open('input.txt', 'r') as inputFile:
|
||||||
|
for line in inputFile:
|
||||||
|
if line == '\n':
|
||||||
|
elves.append(total)
|
||||||
|
total = 0
|
||||||
|
else:
|
||||||
|
total += int(line)
|
||||||
|
|
||||||
|
topThree = 0
|
||||||
|
for i in range(3):
|
||||||
|
topThree += max(elves)
|
||||||
|
elves.remove(max(elves))
|
||||||
|
|
||||||
|
print(topThree)
|
Reference in New Issue
Block a user