diff options
| author | nekineki <nekineki@nekineki.net> | 2022-12-11 14:47:27 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2022-12-11 14:50:32 +0100 |
| commit | fe75c10e350743a1c078f065d69556fecf825ca5 (patch) | |
| tree | 956556a564c9329346dc9d8b1535dc5e365f3d55 /2022/day01.py | |
| parent | a74d2dc54aef546664bcc8c81eb8e01a93e94391 (diff) | |
move files around, update paths
Diffstat (limited to '2022/day01.py')
| -rwxr-xr-x | 2022/day01.py | 23 |
1 files changed, 23 insertions, 0 deletions
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])) + + |
