Skip to content

Instantly share code, notes, and snippets.

@LXZE
Created April 12, 2016 17:52
Show Gist options
  • Save LXZE/4ebd4b29464a16683d05941b991a1c6b to your computer and use it in GitHub Desktop.
Save LXZE/4ebd4b29464a16683d05941b991a1c6b to your computer and use it in GitHub Desktop.
Google Codejam 2016 Qualification round : Revenge of the Pancakes
f = open("input.in","r")
w = open("output.txt","w")
num = f.readline()
for it in range(0,int(num)):
pancakes = f.readline().rstrip('\n')
res = 0
state = ''
txt = ''
for ch in pancakes:
if state != ch:
txt+=ch
state = ch
if txt[0] == '-':
res += 1
txt = txt[1:]
for ch in txt:
if ch == '-': res+=2
print("Case #{0}: {1} ".format(it+1,res))
w.write("Case #{0}: {1}\n".format(it+1,res))
w.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment