Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Regex solution solution in Clear category for Bird Language by kkkkk
import re
VOWELS = "aeiouy"
def translate(phrase):
#result = re.sub(r'([aeiouy])\1\1', r'\1', phrase)
#result = re.sub(r'([^ aeiouy])[aeiouy]', r'\1', result)
# The above two lines may be more readable than those below.
result = re.sub(r'([{}])\1\1'.format(VOWELS), r'\1', phrase)
result = re.sub(r'([^ {}])[{}]'.format(VOWELS, VOWELS), r'\1', result)
return result
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert translate("hieeelalaooo") == "hello", "Hi!"
assert translate("hoooowe yyyooouuu duoooiiine") == "how you doin", "Joey?"
assert translate("aaa bo cy da eee fe") == "a b c d e f", "Alphabet"
assert translate("sooooso aaaaaaaaa") == "sos aaa", "Mayday, mayday"
July 22, 2014