Skip to content
Snippets Groups Projects

Advent of Code 2022 day 1

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by s91149
    Edited
    calories.py 259 B
    with open('inputs/input.txt') as f:
        input = f.read()
    
    elves = input.split('\n\n')
    totals = [
        sum([int(num) for num in elf.split('\n') if num])
        for elf in elves
    ]
    totals.sort(reverse=True)
    
    print(totals[0])
    print(totals[0] + totals[1] + totals[2])
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment