Created
December 4, 2017 07:28
-
-
Save ryu1-1uyr/6deedff0263944e4a16771ea4e17492f to your computer and use it in GitHub Desktop.
https://paiza.jp/challenges/212/show 動くけど未完成、バイトコード使えば良いのでは? このまま続けると階層エグくなりそう
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
# coding: utf-8 | |
typeKey = input() | |
keyLeng = len(typeKey) | |
flag = 0 | |
ans = 0 | |
for i in range(keyLeng): | |
if i == keyLeng - 1 : | |
break | |
print(typeKey[i],typeKey[i+1],ans) | |
if typeKey[i] == "t": | |
flag = 1 | |
elif typeKey[i] == "g": | |
flag = 2 | |
elif typeKey[i] == "b": | |
flag = 3 | |
if flag == 1 and typeKey[i+1] == "y": | |
ans += 1 | |
if typeKey[i+1] == "u": | |
ans += 1 | |
elif typeKey[i+1] == "h": | |
ans += 1 | |
elif typeKey[i+1] == "y": | |
ans +=1 | |
else : | |
flag = 0 | |
if flag == 2 and typeKey[i+1] == "h": | |
ans += 1 | |
if typeKey[i+1] == "j": | |
ans += 1 | |
elif typeKey[i+1] =="y": | |
ans += 1 | |
elif typeKey[i+1] =="n": | |
ans += 1 | |
elif typeKey[i+1] == "h": | |
ans +=1 | |
else : | |
flag = 0 | |
if flag == 3 and typeKey[i+1] == "n": | |
ans += 1 | |
if typeKey[i+1] == "h": | |
ans+=1 | |
elif typeKey[i+1] == "m": | |
ans +=1 | |
elif typeKey[i+1] == "n": | |
ans +=1 | |
else : | |
flag = 0 | |
if typeKey[i] == "y": | |
flag = 4 | |
elif typeKey[i] =="h": | |
flag = 5 | |
elif typeKey[i] == "n": | |
flag = 6 | |
if flag == 1 and typeKey[i+1] == "t": | |
ans += 1 | |
if typeKey[i+1] == "r": | |
ans += 1 | |
elif typeKey[i+1] == "g": | |
ans += 1 | |
elif typeKey[i+1] == "t": | |
ans += 1 | |
else : | |
flag = 0 | |
if flag == 2 and typeKey[i+1] == "g": | |
ans += 1 | |
if typeKey[i+1] == "t": | |
ans += 1 | |
elif typeKey[i+1] =="b": | |
ans += 1 | |
elif typeKey[i+1] =="f": | |
ans +=1 | |
elif typeKey[i+1] == "g": | |
ans += 1 | |
else : | |
flag = 0 | |
if flag == 3 and typeKey[i+1] == "b": | |
ans += 1 | |
if typeKey[i+1] == "g": | |
ans+=1 | |
elif typeKey[i+1] == "v": | |
ans +=1 | |
elif typeKey[i+1] == "b": | |
ans += 1 | |
else : | |
flag = 0 | |
flag = 0 | |
print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment