Japt, (削除) 39 (削除ここまで) 37 bytes
They said it would be ugly, but I didn't listen... and it was:
̧ò ®efQ="%y+" ?Z£XrQZg°T fQP PÃ:ZÃc ̧
Explanation
̧ ò ® efQ="%y+" ?Z£ XrQ Zg° T fQ P PÃ :ZÃ c ̧
UqS ò mZ{Zef"%y+" ?ZmXYZ{Xr"%y+"Zg++T f"%y+"P P} :Z} c qS
Implicit: U = input string, such as "abc def ghi jkl mno"
UqS Split on spaces, splitting into words. ["abc","def","ghi","jkl","mno"]
ò Group into runs of two items. [["abc","def"],["ghi","jkl"],["mno"]]
mZ{ For each pair Z:
Zef"%y+"? If not every item contains a run of vowels (%y = [AEIOUYaeiouy]),
:Z return Z. [ ["ghi","jkl"] ]
ZmXYZ{ Otherwise, for each item X in Z:
Xr"%y+" Replace each run of vowels with
Zg++T the item at the next index in Z, [["def","abc"] ["mno"]]
f"%y+"P but only the first run of vowels. [["e", "a" ] ["o" ]]
P Replace only for the first match. [["ebc","daf"] ["mno"]]
}
} [["ebc","daf"],["ghi","jkl"],"mno"]]
c Flatten back into a single array. ["ebc","def","ghi","jkl","mno"]
qS Re-join on spaces. "ebc daf ghi jkl mno"
Implicit: output result of last expression
ETHproductions
- 50.3k
- 6
- 96
- 241