Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
re.sub(..., repl=lambda) solution in Clear category for Bird Language by vnkvstnk
import re
VOWELS = "aeouiy"
def translation(phrase):
# Creating regexs to match the bird's conversions
cons_vowel = re.compile(f"([^{VOWELS} ])[{VOWELS}]")
three_vowels = re.compile(f"([{VOWELS}])\\1{{2}}")
# Replacing consonant followed by vowel with the consonant
phrase = re.sub(cons_vowel, repl=lambda x: x.group()[0], string=phrase)
# Replacing three consecutive vowels with one
phrase = re.sub(three_vowels, repl=lambda x: x.group()[0], string=phrase)
return phrase
May 27, 2019