def replacements(s):
t = s.replace("{}","")
while(t != s):
s = t
t = s.replace("{}","")
return len(t)/2
Ah bummer. Found something wrong with it.
[edit]Hoping the fuck-ups have ceased.
def replacements(s):
t = s.replace("{}","")
while(t != s):
s = t
t = s.replace("{}","")
count = 0
s = t.lstrip("}")
count += (len(t)-len(s))/2 + (len(t)-len(s))%2
t = s.rstrip("{")
count += (len(s)-len(t))/2 + (len(s)-len(t))%2
return count + len([x for x in t if x == "{"]) - len(t)/2
print replacements("}{}}}{{{")