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)