Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Combining Celebrity Names by oleg.sidorov.ds
import re
def brangelina(first: str, second: str) -> str:
a = []
for item in re.findall(r"([^aeiou]*)([aeiou]+)", first):
a += [item[0], item[1]]
a = ''.join([x for x in a[:max(1, len(a)-3)]])
b = ''.join(re.findall(r"[^aeiou]*([aeiou]+\w*)", second))
return a + b
print("Example:")
print(brangelina("brad", "angelina"))
# These "asserts" are used for self-checking
assert brangelina("brad", "angelina") == "brangelina"
assert brangelina("angelina", "brad") == "angelad"
assert brangelina("sheldon", "amy") == "shamy"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 18, 2023