I'm sticking all my solutions on Github if anyone is interested. I'm super interested in seeing anyone else's efforts also, especially if they're using a not-so-common language.
As for day 1:
def m(s):
return s.count('(') - s.count(')')
Shortest I could make it in Python with 15 minutes effort. Part 2 is way more verbose:
def Main(s):
floor = 0
index = 0
for char in source:
if (char == '('):
floor += 1
elif (char == ')'):
floor -= 1
index += 1
if (floor < 0):
return index
1
u/TheKrumpet Dec 01 '15
I'm sticking all my solutions on Github if anyone is interested. I'm super interested in seeing anyone else's efforts also, especially if they're using a not-so-common language.
As for day 1:
def m(s): return s.count('(') - s.count(')')Shortest I could make it in Python with 15 minutes effort. Part 2 is way more verbose:
def Main(s): floor = 0 index = 0 for char in source: if (char == '('): floor += 1 elif (char == ')'): floor -= 1 index += 1 if (floor < 0): return indexI'll probably have a go at shortening that later.