Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Duck, duck, goose!

Remember the kids game, 'Duck, Duck, Goose'? No? Me neither.

The challenge

  • Print the word 'duck' on individual lines an indeterminate amount of times.
  • Print the word 'goose'.
  • Your program ends.

The rules

  • Attempt to play the game in the fewest bytes.
  • There must be at least one duck.
  • There must be exactly one goose, at the end of the list.
  • There must be exactly one bird on each line. No empty lines.
  • The case of the outputted strings is irrelevant.
  • White-space within a line is fine.
  • Your program must finish.
  • Your program must not consistently produce the same number of ducks.

Have fun!


Please note: This question is not a duplicate of Shortest code to produce non-deterministic output

Reasons include:

  • The association to a childrens' game
  • The defined start and end requirements of the result string. There is no specified output in the other challenge.
  • Answers For the other, non-duplicate challenge are in a single-digit number of bytes. The average for this one is around 30, or there about.
  • By the amount of overlap between this challenge and that one, any code-golf question including the 'random' tag is a duplicate. Should we delete them all?
  • The code answers for this challenge would match the other challenge (in a ridiculously bloated way), but the answers to that challenge would not match this one.

Answer*

Draft saved
Draft discarded
Cancel
5
  • 1
    \$\begingroup\$ You can use 'М since duck is a single word. \$\endgroup\$ Commented Mar 12, 2018 at 16:39
  • 1
    \$\begingroup\$ Beats mine: ['МTΩ#].•zíΘ•» \$\endgroup\$ Commented Mar 13, 2018 at 13:20
  • \$\begingroup\$ @MagicOctopusUrn I really like your infinite loop approach. Your answer is definitely more in the spirit of the challenge (or what it should have been ?) since it can output an infinite amount of ducks. \$\endgroup\$ Commented Mar 13, 2018 at 13:37
  • \$\begingroup\$ @Kaldo still, 15 bytes loses to yours ;) \$\endgroup\$ Commented Mar 13, 2018 at 14:56
  • 1
    \$\begingroup\$ Alternate 14-byter: 'М1Ω.D.•zíΘ•» \$\endgroup\$ Commented Mar 13, 2018 at 16:08

AltStyle によって変換されたページ (->オリジナル) /