Hot answers tagged

171 votes
Accepted

Random script that isn't actually random

C It's important to decide who is buying as quickly as possible, so as not to waste precious drinking time - hence C is the obvious choice in order to get maximum performance: ...
user avatar
  • 2,892
164 votes

Random script that isn't actually random

PHP Couldn't let this go, so here is another one: ...
user avatar
  • 2,551
116 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 ...
user avatar
  • 3,123
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: ...
user avatar
  • 6,727
85 votes

Random script that isn't actually random

Haskell It's too transparent if it always returns the same name so try the following ...
user avatar
  • 2,551
73 votes

Random script that isn't actually random

Bash - maximum simplicity A very simple example - let's avoid any problems by doing it the textbook way. Don't forget to seed the generator from the system clock for a good result! ...
user avatar
  • 4,669
63 votes

Shortest code to produce non-deterministic output

Java 7, 33 30 27 bytes int a(){return hashCode();} Because Java.
user avatar
  • 3,145
61 votes

Shortest code to produce non-deterministic output

MATLAB, 3 bytes why why provides answers to almost any question. A few examples: ...
user avatar
57 votes

Random script that isn't actually random

C# ...
user avatar
  • 42.8k
57 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 ...
user avatar
  • 16.1k
45 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. ...
user avatar
  • 16.2k
44 votes

Random script that isn't actually random

PowerShell $names = @{0='John'; 1='Jeff'; 2='Emma'; 3='Steve'; 4='Julie'} $id = random -maximum $names.Length $names[$id] This will always output ...
user avatar
  • 2,383
42 votes

Random script that isn't actually random

Q show rand `John`Jeff`Emma`Steve`Julie; exit 0;
user avatar
  • 4,315
42 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.
user avatar
  • 543
42 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: ...
user avatar
  • 22.9k
41 votes

Random point on a sphere

Wolfram Language (Mathematica), 20 bytes RandomPoint@Sphere[] Try it online! Does exactly what it says on the tin.
user avatar
  • 15.8k
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 ...
user avatar
40 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") ...
user avatar
  • 3,405
40 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 ...
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 ...
user avatar
  • 3,369
34 votes

Random script that isn't actually random

Perl use strict; my @people = qw/John Jeff Emma Steve Julie/; my @index = int(rand() * 5); print "Person @index is buying: $people[@index]\n";
user avatar
  • 1,895
34 votes

Chaos is an ASCII ladder

Operation Flashpoint scripting language, 643 624 bytes ...
user avatar
  • 16.2k
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 ...
user avatar
  • 1,921
32 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 ...
user avatar
  • 8,865
31 votes
Accepted

Improvise a Hardware Random-Number Generator

Shell Reads a single sample from the microphone stream and prints its least-significant bit, which should be dominated by noise. EDIT: Changed to unmute the microphone ... and everything else too! <...
user avatar
  • 7,577
31 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 ...
user avatar
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 <...
user avatar
  • 12.6k
29 votes
Accepted

Choose The Powerball Numbers!

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

Cracking in progress

HTML/JavaScript, 170 168 167 bytes ...
user avatar
  • 145k

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