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 freeman_lex
def brangelina(first: str, second: str) -> str:
groups, types = [], []
gr = ""
for char in first:
if not gr:
types.append(char in "aeiou")
elif {char in "aeiou", types[-1]} == {True, False}:
groups.append(gr)
gr = ""
types.append(char in "aeiou")
gr += char
groups.append(gr)
if sum(types) == 1:
part1 = groups[0] * (1 - types[0])
else:
vowels_groups = [i for i, v in enumerate(types) if v]
part1 = "".join(groups[:vowels_groups[-2]])
i = 0
while second[i] not in "aeiou":
i += 1
part2 = second[i:]
return part1 + part2
Sept. 17, 2023