""" sum list items seperated bu empty lines and find the maximum """ import numpy as np with open('2022/1/d1-1_input.txt') as filein: text = filein.read() elves = text.split('\n\n') cals = np.array([sum([int(c) for c in elf.split()]) for elf in elves]) print(np.max(cals)) """ now sort and fint the top 3 """ top3 = (np.sort(cals)[::-1][:3]) print(top3) print(np.sum(top3))