48
1
So, last week I posted a challenge to play Duck, Duck, Goose. This lead to a number of Minnesotans commenting about their regional 'Gray duck' variation.
So here's the rules:
Using this list of colours:
Red
Orange
Yellow
Green
Blue
Indigo
Violet
Gray
Write a program to follow these rules:
- Select one of these colours, and prepend it to the word 'duck' and print the result to a new line.
- If the colour was not 'Gray', repeat step 1.
- If the colour was 'Gray', end your program.
Rules which must be followed:
- The program should not consistently print the same number of lines.
- It can begin on 'Gray duck', but should not do consistently.
- There should be exactly one duck on each line and no empty lines are output.
- There should be at least one space between a colour and a duck.
- White space before and after the significant output does not matter.
- The case of the output doesn't matter.
- Colours can be repeated.
- The output doesn't have to contain every colour every time, but it must be possible that your code will output every colour.
- No colours outside the above array can be included.
- Either grey or gray are acceptable in your answer.
- Colours should not consistently be in the same order.
- Aim for the shortest program. Smallest number of bytes wins.
Example output:
Green duck
Orange duck
Yellow duck
Indigo duck
Yellow duck
Gray duck
Thanks to @Mike Hill for first alerting me to this variation.
Any rules on the distribution on outcomes? Because I could generate valid outputs by picking from non-grey colours a random number of times, followed by printing
Grey
once (so I wouldn't have to pick from all of them and check whether I've pickedGrey
). – Martin Ender – 2018-03-19T10:10:16.403@MartinEnder That's fine. "Colours should not consistently be in the same order." matters, but there's nothing to stop you picking grey separately at the end. – AJFaraday – 2018-03-19T10:12:39.397
3Is the alternative spelling "gray" allowed? – 12Me21 – 2018-03-19T12:09:31.607
@12Me21 Curious, tho. Is there a technical reason for that? Or just an aesthetic one? – AJFaraday – 2018-03-19T12:10:49.827
Mostly just aesthetic, though it might affect golfing languages with built in string compression. – 12Me21 – 2018-03-19T12:14:38.683
I believe "gray" should be allowed, even encouraged, because that's how Minnesotans are more likely to spell it. ;)
– DLosc – 2018-03-19T21:22:45.230@DLosc I almost feel like I should change the question now... – AJFaraday – 2018-03-19T21:38:28.610
2In my not-so-humble opinion, you are missing one extremely important duck color. Blue is close, but not precise enough. – cobaltduck – 2018-03-20T23:29:23.277
@cobaltduck We've got blue, we've got green. You can just mix up a batch ;) – AJFaraday – 2018-03-21T09:04:10.943