121
votes
Shortest code to produce non-deterministic output
WinDbg, 1 byte
#
Wow! Never expected a 1 byte solution from WinDbg!
# searches for a disassembly pattern, but since there's no ...
94
votes
Accepted
Display random colored pixels
Minecraft 1.12 Redstone Command Blocks, 4,355 2,872 bytes
(Size determined by saved structure block file size.)
Here is a full YouTube overview, but I'll try to outline the code below.
Setup Routine:
...
68
votes
Shortest code to produce non-deterministic output
MATLAB, 3 bytes
why
why provides answers to almost any question. A few examples:
...
66
votes
Shortest code to produce non-deterministic output
Java 7, 33 30 27 bytes
int a(){return hashCode();}
Because Java.
61
votes
Implement Minceraft
Minecraft, 358 293 277 276 bytes
Implementing Minceraft in Minecraft
Should be run as a set of commands in game. Should be run on a fresh superflat (redstone ready) world.
Byte count is the amount of ...
48
votes
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.
...
46
votes
Accepted
Shortest code to produce non-deterministic output
huh?, 0 bytes
An empty program still produces output. The last lines of the Python interpreter that are executed:
...
44
votes
Shortest code to produce non-deterministic output
R, 1 byte
t
Outputs the function's source code and a memory pointer address which changes with every (re-)start of R.
43
votes
Random point on a sphere
Wolfram Language (Mathematica), 20 bytes
RandomPoint@Sphere[]
Try it online!
Does exactly what it says on the tin.
42
votes
Duck, duck, goose!
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")
...
42
votes
Duck, duck, 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 ...
40
votes
Accepted
Alex-style Addition
Pyth, 8
u+G!OTsQ
Try it online
This uses Pyth's second mode on reduce, that looks for repeated input then exits.
Explanation
...
38
votes
Simulating Exploding Dice
x86 Machine Code (for Intel Ivy Bridge and later), 17 bytes
31 C9 0F C7 F0 31 D2 F7 F6 42 01 D1 39 F2 74 F2 C3
The above bytes of code define a function that ...
34
votes
Shortest code to produce non-deterministic output
Minecraft, 5 4 bytes
op 8
Used by typing into a server's console or a command block and giving it power. Can be run from the chat interface by prepending a ...
34
votes
33
votes
Shortest code to produce non-deterministic output
Labyrinth, 5 bytes
v
!
@
Either prints 0 or nothing (50% chance each).
Try it online!
There is a very specific case in ...
33
votes
Make your code error, but only sometimes!
Baby Language, 0 bytes
Try it online!
I knew this could be fun with a non-deterministic tarpit! I looked through the category on the Esolang wiki and found this ...
30
votes
This will eventually stop…
C#, 94 85 bytes
My first answer!
using System;s=>{var r=new Random();for(var i=2;r.Next(i++)>0;)Console.Write(s+" ");}
Previous attempt (I liked that <...
29
votes
Accepted
Choose The Powerball Numbers!
Dyalog APL, 10 bytes
(5?69),?26
Dyadic ? is ⍺ distinct random numbers in [1,⍵], and monadic ...
28
votes
27
votes
1/N probability
MediaWiki templates with ParserFunctions, 48 bytes
{{#ifexpr:1>{{#time:U}} mod {{{n}}}|true|false}}
27
votes
Passwordify the string
Labyrinth, 76 bytes
`:_64/"32}
,` (3 :=-{
"`{"; _v2$ ;`3
"`".:@ ; ".5(`3.
< "" `^`;>
Another collab with @MartinBüttner and on the more insane ...
26
votes
Accepted
Pick a random number between 0 and n using a constant source of randomness
x86 machines with rdrand instruction, 10 bytes
...
25
votes
Shortest code to produce non-deterministic output
Inform 7, 6 bytes
x is y
This isn't a valid Inform 7 program, since neither "x" nor "y" has been defined. So this throws an error.
However, ...
25
votes
Write an interpreter for *
*, 0 bytes
Since * has no way of reading input, the default rules allow specifying that the input must be given by concatenating it onto the program.
(... I ...
25
votes
Be big more often
Python, 41 bytes
lambda l:choices(l,l)
from random import*
Attempt This Online! or run it 100000 times
Uses the list itself as the weights.
24
votes
Simulate the Universe!
C++ (2420,2243,2353,1860,1822*.9=1639.8)
Ok, so this is probably the worst ever code golf submission, but it's my first and I had fun. I think it even works. :)
...
24
votes
Random Golf of the Day #7: A distinctly random character
MATL, 6 Characters
1Y2Xr)
Explanation:
Xr Take a normally distributed random number
) Use ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
random × 345code-golf × 319
string × 61
ascii-art × 39
number × 23
game × 23
array × 16
math × 13
generation × 13
grid × 11
graphical-output × 11
permutations × 11
kolmogorov-complexity × 10
code-challenge × 9
combinatorics × 9
probability-theory × 9
popularity-contest × 8
geometry × 8
sequence × 7
integer × 7
animation × 7
arithmetic × 5
sorting × 5
open-ended-function × 5
restricted-source × 4