summary refs log tree commit diff stats
path: root/day1.py
diff options
context:
space:
mode:
Diffstat (limited to 'day1.py')
-rw-r--r--day1.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/day1.py b/day1.py
new file mode 100644
index 0000000..aa328b9
--- /dev/null
+++ b/day1.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+with open('day1.txt') as data:
+    floors = data.read().strip()
+# part 1
+print(sum(map(lambda x: 1 if x == '(' else -1, floors)))
+
+# part 2
+floor = 0
+for i, char in enumerate(floors):
+    if char == '(':
+        floor += 1
+    else:
+        floor -= 1
+    if floor == -1:
+        print(i+1)
+        break