Created
September 2, 2009 20:56
-
-
Save savonarola/179950 to your computer and use it in GitHub Desktop.
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
st = gets.chomp | |
w = st.dup | |
correct = true | |
l = st.length | |
i=0 | |
while i<l | |
if w[i..i]=='z' | |
w[i..i]='T' | |
else | |
if (w[i..i] != 'a')and(w[i..i] !='b') | |
correct=false | |
end | |
end | |
i=i+1 | |
end | |
if not correct | |
puts 'Izn\'t correct simbols' | |
else | |
w_old=w.dup | |
while w.length>1 | |
w=w.gsub('aT','T') | |
w=w.gsub('bTT','T') | |
if(w==w_old) | |
w='N' | |
end | |
w_old=w.dup | |
end | |
if w=='T' | |
puts st+' - corret word' | |
else | |
puts st+' - uncorrect word' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment