# Questions tagged [random]

Tasks involving random numbers and/or output.

259 questions
Filter by
Sorted by
Tagged with
3k views

### Build an ASCII Fibonacci Clock

Someone built a really fancy clock using Fibonacci numbers, which looks really nice but is fairly unusable. Just the way we like it! Let's recreate this. The clock is made up of 5 sections ...
236 views

### Looping Random Number Generator [closed]

I'm not even sure if this is even possible, but I think it's worth a shot. The Challenge Code/conceptualize a pseudo-random number generator that has the potential to produce results evenly spaced ...
4k views

### Death By Shock Probe: That's a lot of dice

In the webcomic Darths & Droids, Pete, who plays R2-D2 in the fictional roleplaying campaign around which the comic is based, once claims (warning: potential spoilers in the linked comic) that, ...
744 views

### Theseus' New Ship

The Ship of Theseus is an old question that goes something like: If a ship has had all of its original parts replaced, is it still the same ship? For this golf, we're going to slowly replace "...
3k views

### Random Golf of the Day #4: The Bertrand Paradox

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
1k views

### Draw a Random Walk with Slashes

Write a program or function that takes in a positive integer N (via stdin/command line/function arg) and prints or returns a string representation of a two dimensional random walk that is N steps long,...
71 views

### Random arithmetic quiz [duplicate]

Given a and b as two random numbers from 0 to 10 and op as a random symbol of arithmetic ...
197 views

### Generate a random floating point number between 2 limits [closed]

This challenge is to generate a random floating-point number between 2 limits. You may use any language so long as it can be called from the command line, and runs on linux. It must also be able to ...
816 views

### Drawing an Image Based on a Trace of its Hue

Introduction Local genius Calvin's Hobbies recently challenged us to trace the hue of an image. It is recommended to read his challenge beforehand, but to highlight the main points: The trace of hue ...
4k views

### Monte Carlo estimator of Pi

Happy Pi Day everyone! For no reason at all, I'm trying to construct a Monte Carlo estimator of Pi that is as short as possible. Can we construct one that can fit in a tweet? To clarify, what I have ...
944 views

### Randomised list, formatted nicely

Challenge Task Given a number N, output 2 NxN squares; each line of each square is a random permutation of [0, N); the squares are separated by a newline Rules ...
1k views

### Rubik's Cube Scrambles

Your task is to create a random sequence of moves, which can be used to scramble a Rubik's Cube. Such a scramble is made up of exactly 25 moves. Each move consist of of the letters ...
2k views

### Random Golf of the Day #3: Integer Partitions

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
2k views

### Random Golf of the Day #2: Numbers from a Normal Distribution

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
6k views

### Random Golf of the Day #1: Shuffle an Array

About the Series I will be running a little series of code-golf challenges revolving around the theme of randomness. This will basically be a 9-Hole Golf Course, but spread out over several questions....
2k views

### Generate any random integer

Your program/function should output exactly one integer output any integer with positive probability output an integer greater than 1.000.000 or less than -1.000.000 with at least with 50% ...
1k views

### tiny diamond square algorithm

The diamond square algorithm is a fractal terrain (heightmap) generating algorithm. You can find a nice description how it works here: http://www.gameprogrammer.com/fractal.html (Used as a reference.)...
1k views

### Implement a PCG

What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator. ...
2k views

### Reassuring parables

Quite a few people here are probably avid XKCD readers. So, I figure I'd challenge you guys to do something that Megan can do easily: make a script that generates thousands of reassuring parables ...
221 views

### Create an array of unique ints in a set range [closed]

Goal: Write a piece of code that produces a array containing all integer values in a set range in random order (upper and lower bounds included). Use any language you like, but use as little built-in ...
4k views

### Play the Chaos Game

The Chaos Game is a simple method to generate fractals. Given a starting point, a length ratio r and a set of 2D points, repeatedly do the following: From your set of points, pick one at random (...
7k views

### Improvise a Hardware Random-Number Generator

Your task is to improvise a hardware random-number generator with whatever hardware you have lieing around. Challenge Write a program with the following properties: It prints either ...
3k views

### Randomly pick one number that is different than two other random numbers

Two random numbers A and B have been generated to be either 1, 2, or 3 your job is to randomly pick a third number C that can also be 1,2 or 3. But, C cannot equal A or B. And Yes, A can equal B. If ...
924 views

### Generate four type-4 GUIDs for me

The type 4 GUID is described by Wikipedia, quoth: Version 4 UUIDs use a scheme relying only on random numbers. This algorithm sets the version number (4 bits) as well as two reserved bits. All ...
20k views

### Random script that isn't actually random

As a little joke in the office someone wanted a script that randomly picks a name, and said person will make a round of drinks. Let's call the people John, Jeff, Emma, Steve and Julie. I thought it ...
1k views

### Super fast sampling from a tricky random distribution

This is a micro-optimization challenge. The task is to sample from the maximally skewed stable distribution F(x;1,-1,Pi/2,0). See Table 1 of http://arxiv.org/pdf/0908.3961v2.pdf . It is easiest to ...
3k views

### Generate random PESEL number

From Wikipedia: PESEL is the national identification number used in Poland since 1979. It always has 11 digits, identifies just one person and cannot be changed to another one. It has ...
3k views

### Roll Dungeons and Dragons dice

I want to play Dungeons and Dragons, but I don't have any dice! Your challenge is to roll some D&D dice. The input format specification in Backus-Naur form is: ...
710 views

### Taking the dog for a walk

My dog is barking at me, but I'm too lazy to take him for a walk. I have an idea! I'll get the people at Code Golf to do it for me! Your challenge is to simulate a dog's walk. Here are the rules for ...
9k views

### Shortest code to print ':)' random times [duplicate]

You have to create a code which prints :) a random number of times from 1 to 255 inclusive. Your output may not contain any whitespace. Your score : The ...
2k views

### Generate white noise

The challenge is: generate an audio file made of white noise. Requirements and instructions: Your program must generate an audio file containing only white noise, meaning its intensity is the same ...
2k views

### Random number generation, without built-in random number generation libraries [duplicate]

Task: Make a random number generator. The catch is that you can't use any built-in randomness functions. Your random numbers must be anything between 0 and 100, though they do not have to be floating ...
172 views

### Password Generator [duplicate]

Task: Make a program that generate a 24-digit password. Rule: None of the character can be repeated more than once Must include at least one upcase, one locase, one number, five special ...
9k views

### Random Password Generator

The domain server requires that all employees have a strong, random password conforming to the following rules: Exactly 15 characters long. Keyboard-typeable characters only (as shown in code-type ...
4k views

### Golfing A Weasel Program

Richard Dawkins in his book The Blind Watchmaker, describes a Weasel program. The algorithm can be described as follows: Start with a random string of 28 characters. Valid characters are all ...
2k views

### Random CSS Color code

This blog post about generating random CSS color codes in JavaScript have multiple solutions for generating a random color in JavaScript. The shortest I can find is this: ...
3k views

### Generate a pronounceable word

The challenge is simple: generate a word. Specifications: Word must be pronounceable. This is defined as "alternating between a consonant and a vowel." A consonant is one of the following letters: ...
9k views

### Build a random number generator that passes the Diehard tests

While there are many code golf questions on here involving randomness, I haven't seen one yet that actually asks for building an algorithmic pseudorandom number generator. There's this one that asks ...
880 views

### Non-transitive dice game

Those of you who like Numberphile would be familiar with Dr. James Grime, who described a non-transitive dice game on his channel. The game consists of three 6-faced dice: Die 1: 3,3,3,3,3,6 Die 2: ...
1k views

### Cambridge Transposition

I'm sure most, if not all, of you have come across this at some point or another: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the ...
1k views

### Rolling three dice and show the probabilities

Roll 3 dice, count the two highest two values and add them to the result. Every 1 must be rolled once again. Now show the average throw after 1000000 tries and the probabilities for each result ...
3k views

965 views

### Output a shuffled deck using random input

Input/Output: Input: A uniformly random, infinitely long, string of '0's and '1's, taken from stdin. The string is assumed to be truly random, not pseudo-random. It is uniform in that each ...
1k views

### Dice from Changing Random Generator

Introduction You are given a random integer generator with the following implementation The first invocation always returns 1. The second invocation returns a random integer between 1 and 2. The ...
6k views

### Can you Golf Golf?

You are required to generate a random 18-hole golf course. Example output: [3 4 3 5 5 4 4 4 5 3 3 4 4 3 4 5 5 4] Rules: Your program must output a list of hole ...
2k views

### Generate a (completely deterministic) pseudorandom bit stream

Inspired by Random with your hands tied: The Goal The goal of this challenge is to write a program that generates a pseudorandom bit stream, which is a string of 1s and 0s that appears to be purely ...
1k views

### Generate ASCII wilderness map [closed]

Generate an ASCII wilderness map. Example output: ...
779 views

### Sort, with your hands tied behind your back [closed]

The problem is very simple: write a program that accepts a single unsigned integer from the command line, and prints out that many random numbers on the standard output, in ascending order. For ...
1k views

### Lorem Ipsum Random Code Generation

An IDE developer has hired you to write a program that generates (by printing to stdout) n lines of randomly generated code. They will use your program to create sample code for use in marketing their ...
1k views

### Did I win the lotto?

I just submitted an answer to this question, and then looked about at some news stories about the MegaMillions lottery craze going on right now in the US. This news article stated that an individual ...