diff options
Diffstat (limited to '2015/01/not_quite_lisp2.py')
-rw-r--r-- | 2015/01/not_quite_lisp2.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/2015/01/not_quite_lisp2.py b/2015/01/not_quite_lisp2.py new file mode 100644 index 0000000..a688b3b --- /dev/null +++ b/2015/01/not_quite_lisp2.py @@ -0,0 +1,14 @@ +pos = 1 +floor = 0 +with open("input", encoding="utf-8") as f: + text = f.read() +for char in text: + if char == '(' or char == ')': + if char == '(': + floor += 1 + else: + floor -= 1 + if floor == -1: + print(f"basement position is {pos}") + break; + pos += 1 |