From 8228d8a6c276b83c8b81e4e1b59e46d509411f62 Mon Sep 17 00:00:00 2001 From: Jake Charman Date: Thu, 1 Dec 2022 09:04:52 +0000 Subject: [PATCH] Completed day 1 --- 2022/Day-01/day01-1.py | 14 ++++++++++++++ 2022/Day-01/day01-2.py | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 2022/Day-01/day01-1.py create mode 100644 2022/Day-01/day01-2.py diff --git a/2022/Day-01/day01-1.py b/2022/Day-01/day01-1.py new file mode 100644 index 0000000..db85d1b --- /dev/null +++ b/2022/Day-01/day01-1.py @@ -0,0 +1,14 @@ +#!/usr/bin/python3 + +total = 0 +elves = [] + +with open('input.txt', 'r') as inputFile: + for line in inputFile: + if line == '\n': + elves.append(total) + total = 0 + else: + total += int(line) + +print(max(elves)) diff --git a/2022/Day-01/day01-2.py b/2022/Day-01/day01-2.py new file mode 100644 index 0000000..30e4d9c --- /dev/null +++ b/2022/Day-01/day01-2.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 + +total = 0 +elves = [] + +with open('input.txt', 'r') as inputFile: + for line in inputFile: + if line == '\n': + elves.append(total) + total = 0 + else: + total += int(line) + +topThree = 0 +for i in range(3): + topThree += max(elves) + elves.remove(max(elves)) + +print(topThree)