]> git.friedersdorff.com Git - max/advent_of_code_2021.git/commitdiff
Finish 1_1
authorMaximilian Friedersdorff <max@friedersdorff.com>
Sat, 4 Dec 2021 21:31:17 +0000 (21:31 +0000)
committerMaximilian Friedersdorff <max@friedersdorff.com>
Sat, 4 Dec 2021 21:31:17 +0000 (21:31 +0000)
1_1.py

diff --git a/1_1.py b/1_1.py
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3b41b1d6e40358e215fdd4440a923c541784762b 100644 (file)
--- a/1_1.py
+++ b/1_1.py
@@ -0,0 +1,19 @@
+"""Advent day 1, challenge 1
+
+Count the number of times the input number
+is higher than the previous one
+"""
+
+first = False
+prev_depth = None
+n_increased = 0
+with open("1_1_input.txt") as f:
+    for line in f:
+        depth = int(line)
+        if (prev_depth is not None
+                and depth > prev_depth):
+            n_increased += 1
+
+        prev_depth = depth
+
+print(n_increased)