Write a program or a function that will output a given string in a staircase fashion, writing each part of a word that starts with a vowel one line below the previous part.
For example:
Input: Programming Puzzles and Code Golf
Output: Pr P C G
ogr uzzl and od olf
amm es e
ing
Input
A string containing nothing but letters and spaces.
The string can be passed via STDIN
or function arguments or anything equivalent.
Letters can be lowercase or uppercase.
Inputs are always assumed to follow those rules, you don't need to check for incorrect inputs.
Output
Each time a vowel (that is, a
, e
, i
, o
, u
or y
) is encountered in a word, you must output the rest of the word on the next line (the encountered vowel included), at the correct horizontal position. This rule is recursive, which means that if there are n vowels in the word, it will be written on n+1 lines.
The vowel should be written at the beginning of the next line, and not at the end of the previous line when one is encountered.
Each word starts on the first line, and should thus be formatted independently from other words. Two words are separated by a space.
If a word starts with a vowel, you have to write it starting on the second line.
Test cases
- Input:
Programming Puzzles and Code Golf
Output:
Pr P C G
ogr uzzl and od olf
amm es e
ing
- Input:
The quick brown fox jumps over the lazy dog
Output:
Th q br f j th l d
e u own ox umps ov e az og
ick er y
- Input:
aeiouy
Output:
a
e
i
o
u
y
- Input:
YEAh UppErcAsE VOwEls
Output:
V
Y Upp Ow
E Erc Els
Ah As
E
- Input:
If you only knew the power of the Dark Side
Output:
kn th p th D S
If y onl ew e ow of e ark id
o y er e
u
Scoring
This is code-golf, so the shortest code wins.
The vowel should be written at the beginning of the next line, and not at the end of the previous line when one is encountered.
After some thought, I understand that this means that the move to the next line should happen before the vowel is printed, not after, but it might be worth wording this in a way that is instantly understandable - it took me a while. \$\endgroup\$