Created
April 12, 2016 17:52
-
-
Save LXZE/4ebd4b29464a16683d05941b991a1c6b to your computer and use it in GitHub Desktop.
Google Codejam 2016 Qualification round : Revenge of the Pancakes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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