advent-of-code/2022/python/day01.py

34 lines
581 B
Python
Raw Normal View History

2022-12-09 16:43:00 +00:00
import shared
from pprint import pprint as pp
def run(rows):
elves = []
current_elf = 0
for row in rows:
if row == '':
elves.append(current_elf)
current_elf = 0
continue
current_elf += int(row)
three = 0
for x in range(3):
most = max(elves)
idx = elves.index(most)
elves.pop(idx)
three += most
print(three)
def main():
with open(shared.get_fname(1), "r") as f:
rows = [x.rstrip() for x in f.readlines()]
run(rows)
if __name__ == "__main__":
main()