rj1
about | log | files | refs
commit f0218efba88574dcc3003cf9ee97b076f5187d79
parent e0ee3530d9e355c2c79f2913325878357b8c0113
author: rj1 <[email protected]>
date:   Wed, 30 Nov 2022 23:24:15 -0600

day 1 solution

Diffstat:
A2022/01/solution.py | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/2022/01/solution.py b/2022/01/solution.py @@ -0,0 +1,17 @@ +import os + +base_dir = os.path.realpath(os.path.dirname(__file__)) +with open(base_dir + "/input.txt", "r") as file: + input = file.read().rstrip() + +elves = [] +for elf in input.split("\n\n"): + cc = 0 + for c in elf.split("\n"): + cc += int(c) + elves.append(cc) + +elves = sorted(elves) + +print(elves[1]) +print(elves[-1] + elves[-2] + elves[-3])