Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple, but not too dry solution in Clear category for Bird Language by Alexander_Antonov
import re
VOWELS = "aeiouy"
def translation(phrase):
# Replace consonant+vowel pairs block
for i in set(phrase.replace(' ', '')):
if i not in VOWELS:
phrase = re.sub(fr'{i}[{VOWELS}]', i, phrase)
# Replace triple vowels block
for i in set(phrase.replace(' ', '')):
if i in VOWELS:
phrase = re.sub(fr'{i}{{3}}', i, phrase)
return phrase
if __name__ == '__main__':
print("Example:")
print(translate("hieeelalaooo"))
#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"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Feb. 19, 2020