summaryrefslogtreecommitdiff
path: root/2022/day1/day1.py
diff options
context:
space:
mode:
Diffstat (limited to '2022/day1/day1.py')
-rwxr-xr-x2022/day1/day1.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/2022/day1/day1.py b/2022/day1/day1.py
new file mode 100755
index 0000000..cf2ca85
--- /dev/null
+++ b/2022/day1/day1.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+arr = []
+s = 0
+with open("input.txt") 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]))
+
+