Day 1


In [ ]:
myinput = '/home/fmuinos/projects/adventofcode/2015/ferran/inputs/input1.txt'

Day 1.1


In [11]:
with open(myinput, 'rt') as f:
    line = next(f).rstrip()
    floor = sum([(char == '(') - (char == ')') for char in line])
print(floor)


138

Day 1.2


In [13]:
floor = 0
pos = 0
for char in line:
    pos += 1
    floor += (char == '(') - (char == ')')
    if floor == -1:
        break
print(pos)


1771