Advent of Code 2022 day 1

with open("1.txt") as f:
    lines = f.read().split("\n\n")

def int_or_zero(x):
    if x == "":
        return 0
    return int(x)

def get_calories(x):
    return sum(int_or_zero(y) for y in x.split("\n"))

# part 1
print(max([get_calories(elf_line) for elf_line in lines]))

# part 2
print(sum(sorted([get_calories(elf_line) for elf_line in lines])[-3:]))