Advertisement
desrtfx

Day_01

Dec 1st, 2022 (edited)
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | Source Code | 0 0
  1. #day_01
  2. cals = []
  3. current = []
  4.  
  5. with open("Input_Day01.txt") as data:
  6.     for line in data:
  7.         if line == "\n":
  8.             cals.append(sum(current))
  9.             current = []
  10.         else:
  11.             current.append(int(line))
  12.  
  13. cals.sort()
  14. cals.reverse()
  15.  
  16. print("Part 01: " + str(cals[0]))
  17. print("Part 02: " + str(sum(cals[0:3])))
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement