Write some Random English

1

Your Goal:

Given an odd integer input n greater than 1, generate a random English word of length n. An English word is one in which the odd (1-based) indices are consonants and the even (1-based) indices are vowels, the vowels being aeiou.

Random

For the purposes of this challenge, you are to sample from the vowels and consonants uniformly, with replacement. In other words, each possible English word must be equally likely to appear as an output.

Example Inputs/Outputs

3 -> bab, tec, yiq
5 -> baron, nariz, linog
7 -> murovay, fanafim

Winner:

Winner is the Lowest Byte Count.

Upvote your Favorite one, Top 3 Upvoted will be Honorable Mentions :P

TaylorS

Posted 2020-02-07T19:10:37.980

Reputation: 143

4Welcome to the site. I don't really understand the challenge here. Maybe the sandbox (linked on the right), would be a good place to get feedback. – Post Rock Garf Hunter – 2020-02-07T19:19:40.173

Are we making a function that generates the words? Or should the program simply generate them when run? – sugarfi – 2020-02-07T19:49:46.940

7

Hi there. I've voted to close this as needing additional clarity, but do not fret when this gets closed! It's tough to get a challenge specified up to our standards the first few times you come up with one, so we have a sandbox for you to get feedback on them before they come to the main site. Hope you enjoy your time here, and happy golfing!

– Giuseppe – 2020-02-07T20:46:21.630

4

Be sure to specify what you mean by random. Also, how is the output size specified? Is it also random?

– Luis Mendo – 2020-02-07T21:35:01.780

Some questions for clarification: (1) does this take input, and if so, what is the input and how exactly does it affect the output? (2) What is meant by random? Do we select vowels and consonants with replacement, so bab and babab would each be possible, or without? Does each word generated this way have equal chance of being generated, or does each word have to have a non-zero probability of appearing, or is there some other specific, well-defined distribution you're looking for? I see Luis has asked basically the same questions, but you have not yet addressed them in any way. – Giuseppe – 2020-02-10T18:12:45.083

@Giuseppe no extra details needed... Thats what I meant. I wanted to see who could create vowel and non vowel random words in the least amount of bytes. See the number one answer, they did it right. – TaylorS – 2020-02-12T17:01:31.213

We have some guidelines on things to include in your challenge. If you'd like, I'd be happy to edit this question up to our standards (with your input, of course) so we can get this re-opened and get some upvotes on it! I haven't downvoted it because I think it's a good challenge; it just needs some refinement and it should get a decent amount of attention.

– Giuseppe – 2020-02-12T19:13:00.813

1I've gone ahead and edited it (and voted to re-open), please make edits to it as you feel appropriate! – Giuseppe – 2020-02-12T19:19:31.023

Reminds me of this challenge. Main difference being that this takes length as input. Actually, I'm not sure if that makes this a dupe or not. – Value Ink – 2020-02-14T06:59:04.717

@ValueInk He wants pronouncable words, and y itsnt a vowel, but he includes it anyways. Your able to merge AEIOU and its actually a pronouncable sound, with Y it adds an extra sectional sound, its incorrect – TaylorS – 2020-02-14T15:56:48.423

Answers

5

05AB1E, 14 11 bytes

-3 bytes thanks to Kevin Cruijssen

EžN¸žMšNèΩJ

Try it online!

mabel

Posted 2020-02-07T19:10:37.980

Reputation: 1 489

¸ì can be š, .R can be Ω, and the } can be removed before the join. – Kevin Cruijssen – 2020-02-10T07:49:22.133

oh wow, thank you! @KevinCruijssen – mabel – 2020-02-10T09:07:19.453

2

Stax, 10 bytes

ÇÅφ⌠↑Ñ°↕Yx

Run and debug it

Explanation

FVcVv2l@_@L

F           In range 1 to the input, do this ...
 Vv         Vowels
   Vc       Consonants
     2l     Wrap the two inside a list
       @    Index the constructed list into the counter
            Note that the counter starts at 1,
            so this picks the constants list
            before the vowels list.
        _@  Index by the current counter
            (Stax doesn't have random number support)
          L Wrap the whole stack into a list

a'_'

Posted 2020-02-07T19:10:37.980

Reputation: 1 099

Wow, nice job on this one – TaylorS – 2020-02-13T12:17:32.950

2

GolfScript, 36 bytes

,{['aeiou'.123,97>^]\2%=.,rand=}%''+

Try it online!

a'_'

Posted 2020-02-07T19:10:37.980

Reputation: 1 099

You can save some bytes by using ['aeiou'.123,97>^] instead of your long string. Generates the characters 98-123, then removes the vowels. Plus, they're in two distinct arrays too, which saves you a bunch too. the string and 21/ can be removed, meaning you're down 31 chars and up 18, netting 13.

,{['aeiou'.123,97>^]\2%=.,rand=}%''+

This worked for me. – Mathgeek – 2020-02-14T14:18:04.870

1

Perl 5, 69 bytes

say map{([a,e,i,o,u],[grep!/[eiou]/,b..z])[$_%2][rand$_%2*16+5]}1..<>

Try it online!

Xcali

Posted 2020-02-07T19:10:37.980

Reputation: 7 671

1

Ruby, 76 bytes

Basic recursive function that adds a consonant and a vowel each time until there's only one character left, at which point it adds just the consonant.

f=->n{[*?b..?z].grep(/[^eiou]/).sample+(n<2?'':'aeiou'.chars.sample+f[n-2])}

Try it online!

Value Ink

Posted 2020-02-07T19:10:37.980

Reputation: 10 608