Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
2 simple regexes solution in Clear category for Bird Language by gennadylaptev
VOWELS = "aeiouy"
#from string import ascii_lowercase as alphabet
#CONSONANTS = [letter for letter in alphabet if VOWELS.count(letter) == 0]
import re
def translation(phrase):
regex1 = r'([bcdfghjklmnpqrstvwxz])([aeiouy])'
regex2 = r'([aeiouy])([aeiouy][aeiouy])'
phrase1 = re.sub(regex1, r'\1', phrase)
phrase2 = re.sub(regex2, r'\1', phrase1)
return phrase2
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"
April 7, 2016
Comments: