summaryrefslogtreecommitdiff
path: root/2015/01/not_quite_lisp2.py
blob: a688b3b838f75742b1f19393f984cf93379aac0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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