Note: the title was misspelled intentionally.
Given a string s, swap the first vowel runs of every 2 words. For this challenge, y is considered a vowel.
For example, given an input of "great day sir":
1. Input: "great day sir"
2. Identify pairs of words: "[great day] [sir]" (No word for sir to pair with)
3. Identify the first vowel runs in each word: "[gr[ea]t d[ay]] [s[i]r]"
4. Swap the vowel runs in each pair: "[gr[ay]t d[ea]] [s[i]r]"
5. Return/print: "grayt dea sir"
When there are vowel runs of different lengths, you still swap the whole runs. When a word has more than one vowel runs, you still only swap the first one. When the first or second word of a pair of words does not have a vowel, then you do not swap the vowels for those words.
You may assume that the input only consists of one case of alphabetic letters and the literal space or another constant delimiter.
Standard methods of I/O, standard loopholes apply. Leading/trailing whatevers are okay.
Test cases:
Input -> Output
"great day sir" -> "grayt dea sir"
"ppcg is the best" -> "ppcg is the best" (When there is no vowel to swap, don't swap vowels."
"this is a test case" -> "this is e tast case"
"loooooooooooooong word" -> "long woooooooooooooord"
"great night" -> "grit neaght"
"anything goes" -> "oenything gas"
"qwrtpsdfghjklzxcvbnm aaaaaaaa hi there" -> "qwrtpsdfghjklzxcvbnm aaaaaaaa he thire"
"this is a long test case in case you could not tell" -> "this is o lang tast cese an cise ou cyould net toll"
ppcg is awesome
becomeppcg is awesome
orppcg as iwesome
? \$\endgroup\$this is a long test case in case you could not tell
should bethis is o lang tast cese an cise ou cyould net toll
, since the vowel runsyou
andou
would be swapped. \$\endgroup\$