Duck, duck, goose!
Operation Flashpoint scripting language, 48 bytes
f={s="duck\n";s+([s,""]select random 1)+"goose"}
Always prints either one or two ducks.
random 1
returns a (floating point) number between 0 and 1. That number is passed as an argument to select
along with the array [s,""]
. The random number is then rounded to the nearest integer (either 0 or 1), and the array element at that index is selected from the array.
Call with:
hint call f
Output:
Alternative 56 bytes version:
f={s="duck\n";format[s+"%1goose",[s,""]select random 1]}
World of Warcraft 81 Bytes
Here's a macro that you can run in World of Warcraft.
/run for x=1,random(1,9) do SendChatMessage("Duck") end; SendChatMessage("Goose")
Minecraft <1.13, 72 54 bytes
Sorry, I had to.
Instructions:
- Create a new Minecraft world in Creative Mode
- Find the save folder for that world, and place the following code in
data/functions/minecraft/ddg.mcfunction
- Run
/function ddg
in the game console
How it works:
Outputs the word "duck" for every entity in the world, then outputs the word "goose". Since entities are constantly spawning and despawning, the number of "duck"s will not be consistent. I used tellraw
instead of the much shorter say
because say
outputs the name of the entity, while tellraw
outputs exactly what it is told.
execute @e ~ ~ ~ tellraw @a "duck"
tellraw @a "goose"
Screenshot
Edit: Changed {"text":"duck"} to just "duck" (and the same with "goose")