Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear and documented solution with regular expressions with group replacing solution in Clear category for Bird Language by bsquare
import re
VOWELS = "aeiouy"
def translation(phrase):
# Removes all 2 duplicates/extra vowels.
phrase_without_duplicates = re.sub(r"([" + VOWELS + r"])\1\1", r"\1", phrase)
# Removes random vowel after consonant letter.
# N.B.: we ignore space characters too (note the \s), ensuring to match only letter
# (taking care it is clearly stated in the mission there is NO punctuations characters).
phrase_without_random = re.sub(r"([^\s" + VOWELS + r"])[" + VOWELS + r"]", r"\1", phrase_without_duplicates)
return phrase_without_random
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!")
July 27, 2019