From fe75c10e350743a1c078f065d69556fecf825ca5 Mon Sep 17 00:00:00 2001 From: nekineki Date: Sun, 11 Dec 2022 14:47:27 +0100 Subject: move files around, update paths --- 2022/day01.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 2022/day01.py (limited to '2022/day01.py') diff --git a/2022/day01.py b/2022/day01.py new file mode 100755 index 0000000..3ae9953 --- /dev/null +++ b/2022/day01.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +arr = [] +s = 0 +with open("in/day01.pzl") as f: + for line in f: + line = line.strip() + if line == '': + arr.append(s) + s = 0 + else: + s += int(line) + if s != 0: + arr.append(s) + s = 0 + +# print(arr) +print(max(arr)) + +arr = sorted(arr, key=lambda x: -x) +print(sum(arr[:3])) + + -- cgit v1.2.3