Added old 2022 AoC solves
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
with open('input') as f:
|
||||
list_array = f.readlines()
|
||||
|
||||
sun_array = []
|
||||
count = 0
|
||||
temp = 0
|
||||
max = 0
|
||||
for x in list_array:
|
||||
|
||||
if x != '\n':
|
||||
temp += int(x)
|
||||
else:
|
||||
print('total: ' + str(temp))
|
||||
if temp > max: max = temp
|
||||
temp = 0
|
||||
print('total: ' + str(temp))
|
||||
print('The Elf with the most Calories carry ' + str(max))
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
with open('input') as f:
|
||||
list_array = f.readlines()
|
||||
|
||||
sun_array = []
|
||||
count = 0
|
||||
temp = 0
|
||||
max = 0
|
||||
top3 = []
|
||||
for x in list_array:
|
||||
|
||||
if x != '\n':
|
||||
temp += int(x)
|
||||
else:
|
||||
#print('total: ' + str(temp))
|
||||
if temp > max: max = temp
|
||||
top3.append(temp)
|
||||
temp = 0
|
||||
|
||||
#print('total: ' + str(temp))
|
||||
top3.append(temp)
|
||||
print('The Elf with the most Calories carry ' + str(max))
|
||||
print('The top 3 Elves are carrying ' + str(sum(sorted(top3,reverse=True)[:3])) + ' Calories')
|
||||
|
||||
Reference in New Issue
Block a user