Hot answers tagged

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 ...
milk's user avatar
  • 3,173
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: ...
BradC's user avatar
  • 6,757
68 votes

Shortest code to produce non-deterministic output

MATLAB, 3 bytes why why provides answers to almost any question. A few examples: ...
Stewie Griffin's user avatar
66 votes

Shortest code to produce non-deterministic output

Java 7, 33 30 27 bytes int a(){return hashCode();} Because Java.
Poke's user avatar
  • 3,175
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 ...
Okx's user avatar
  • 16.4k
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. ...
Steadybox's user avatar
  • 16.5k
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: ...
mbomb007's user avatar
  • 23.3k
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.
chrki's user avatar
  • 563
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.
att's user avatar
  • 19.8k
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") ...
Kelly Lowder's user avatar
  • 3,475
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 ...
James Westman's user avatar
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 ...
FryAmTheEggman's user avatar
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 ...
Cody Gray - on strike's user avatar
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 ...
Pavel's user avatar
  • 9,369
34 votes

Chaos is an ASCII ladder

Operation Flashpoint scripting language, 643 624 bytes ...
Steadybox's user avatar
  • 16.5k
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 ...
Martin Ender's user avatar
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 ...
AviFS's user avatar
  • 2,111
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 <...
Charlie's user avatar
  • 12.8k
29 votes
Accepted

Choose The Powerball Numbers!

Dyalog APL, 10 bytes (5?69),?26 Dyadic ? is ⍺ distinct random numbers in [1,⍵], and monadic ...
lirtosiast's user avatar
  • 21.4k
28 votes

Cracking in progress

HTML/JavaScript, 170 168 167 bytes ...
Neil's user avatar
  • 166k
27 votes

1/N probability

MediaWiki templates with ParserFunctions, 48 bytes {{#ifexpr:1>{{#time:U}} mod {{{n}}}|true|false}}
DuhHello's user avatar
  • 499
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 ...
Sp3000's user avatar
  • 61.7k
26 votes
Accepted

Pick a random number between 0 and n using a constant source of randomness

x86 machines with rdrand instruction, 10 bytes ...
Margaret Bloom's user avatar
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, ...
Draconis's user avatar
  • 611
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 ...
hmakholm left over Monica's user avatar
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.
MTN's user avatar
  • 771
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. :) ...
MichaelS's user avatar
  • 371
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 ...
Dennis Jaheruddin's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible