17
3
In the English language, a surefire way to make a pronounceable nonsense letter combination is to make it entirely out of consonant-vowel pairs, e.g., Wu ko pa ha, or, Me fa ro, consonant first, followed by vowel.
Challenge:
Write a program or function that will, given a user-specified number of letters, create a random name using this principle. It's that simple.
Input:
An integer greater than or equal to 2 which designates the required number of letters in the output. Input can be taken from STDIN, command line arguments, or function arguments.
Output:
A string of the given length containing randomly selected consonant-vowel pairs. It can be printed to STDOUT or closest alternative or returned in the case of a function.
Rules:
- Each consonant of the English alphabet should have equal probability of being selected for the first character of each pair, and each vowel of the English alphabet should have equal probability of being selected for the second character of each pair.
- Letter pairs may be repeated.
- Since this is a name, the first letter must be capitalized.
- If the input is odd, a randomly selected letter pair in the name should have y or h appended to the end. The choice of y or h should be random as well.
- Standard loopholes are not permitted.
- Smallest code in bytes wins.
Letter definitions:
Consonants:
bcdfghjklmnpqrstvwxyz
Vowels:
aeiou
Example I/O:
Input: 6
Output: Mefaro
Input: 9
Output: Wukohpaha
Enjoy!
3And by the way, welcome to Programming Puzzles and Code Golf.SE :) – trichoplax – 2015-07-07T02:29:11.277
I think my new format is more clear. Is it? @trichoplax – jman294 – 2015-07-07T15:19:16.750
1
I post all my potential questions in the sandbox where they can get plenty of feedback before posting here. It makes things easier - I recommend it for future questions.
– trichoplax – 2015-07-07T16:31:10.890Thanks, @alex, Since this is my first question, I now know some good technique on how to use this site. I have learned a lot, and I hope my next question will be better! – jman294 – 2015-07-07T17:04:49.900
I'll try my best to clear everything up with no major edits on my next question – jman294 – 2015-07-07T17:06:43.117
Thanks for everyone who as helped me make this question the best it can be, I didn't know sandbox was a thing, but will use it in the future. the edits are great@AlexA. – jman294 – 2015-07-07T17:11:18.410
How come an input of 9 gives
Wukohpaha
and notWukopahah
? – ASCIIThenANSI – 2015-07-07T17:30:47.097an input of 9 should give Wukopahah, @ASCIIThenANSI, I fixed that minor error – jman294 – 2015-07-07T17:33:27.963
1@ASCIIThenANSI Per rule #4, a randomly selected letter pair will get a y or h. In that example, it was ko that got the h, not ha. jman: If that's not what you had in mind, better modify the rules quick before more answers start coming in! – Alex A. – 2015-07-07T17:46:49.750
@AlexA. Ah, OK. I saw it as "getting appended to the end of the word". – ASCIIThenANSI – 2015-07-07T17:48:07.097
I changed my edit back. I like your way better, Alex. – jman294 – 2015-07-07T17:49:12.513