Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Bird Language by Kurush
# migrated from python 2.7
VOWELS = "aeiouy"
def translation(phrase):
words = phrase.split(" ")
translated_words = []
for word in words:
translated_words.append(translate_word(word))
return " ".join(translated_words)
def translate_word(word):
for vowel in VOWELS:
word = word.replace(vowel * 3, vowel)
copy_word = ""
i = 0
while i < len(word):
copy_word += word[i]
if word[i] not in VOWELS:
i += 1
i += 1
return copy_word
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert translation("hieeelalaooo") == "hello", "Hi!"
assert translation("hoooowe yyyooouuu duoooiiine") == "how you doin", "Joey?"
assert translation("aaa bo cy da eee fe") == "a b c d e f", "Alphabet"
assert translation("sooooso aaaaaaaaa") == "sos aaa", "Mayday, mayday"
June 25, 2014
Comments: