Questions tagged [random]

Tasks involving random numbers and/or output.

351 questions
Filter by
Sorted by
Tagged with
1k views

Flip a coin in Lost

Lost is a 2-D programming language where the start position and direction of the ip are entirely random. Today we will be writing a Lost program which uses this randomness to simulate a coin flip. A ...
• 98.8k
3k views

Find the odd one out

Challenge The goal of this challenge is to generate and output a $16 \times 32$ (height $\times$ width) grid where all cells contain a decoy character, except for a random single cell that ...
• 2,213
2k views

Spot The Difference

Challenge Generate two $16 \times 16$ grids, each initially filled with "@" symbols and spaces. Each cell in the grids should be independently filled with an "@" or a space, with ...
• 2,213
1 vote
292 views

Alternating Random Series Sum To $N$ [closed]

Challenge Given a positive integer $N \ge 3$, generate an alternating series of $N$ random numbers within the range $[1, N]$, such that their sum equals $N$. Expressed mathematically as N = ...
• 2,213
503 views

3D Hide & Seek Word Puzzle

Challenge Create a 3D word puzzle where the cube's dimensions match the length of the input word. The uppercase word (A-Z) must be validly placed within the cube in one of the fixed orientations: ...
• 2,213
1 vote
292 views

Yin-Yang Table Generator [closed]

I want an n*n table that is filled with black or white and the following conditions are satisfied in it: All cells of a 2*2 square in this table should not be the same color. All black and white ...
235 views

Bingo Cards SVG Code [duplicate]

Generate the contents of an SVG file containing 6 bingo cards. Winner is the one that uses the shortest code. A qualifying answer has an output that can be directly pasted in a blank to get the ...
• 175
3k views

Be big more often

Related You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But ...
2k views

XOR of independent Bernoulli variables

In probability theory, a Bernoulli variable is a random variable which has a single parameter $p$, and is equal to 1 with probability $p$, and 0 with probability $1-p$. In this challenge, there ...
• 10.6k
3k views

Elect the Doge of Venice

The Venetian election system was... complicated. The Great Council came together and put in an urn the ballots of all the councilors who were older than 30. The youngest councilor went to St Mark's ...
• 1,373
816 views

A randomly colored walk

Given two inputs, a distance $d$ and a number $n$ output a list of $n$ random colors which each have distance $d$ from the previous. Background A random walk is a path which is defined by ...
• 4,467
943 views

Random point inside boundary

Given an ASCII art with simple closed paths using | and - (pipes and dashes), output a random point inside the boundary. Eg. ...
• 9,408
2k views

Generate an emoticon

Your task is to generate an emoticon of three characters, the first character being one eye, the second the mouth, and the third another eye. Each eye is a random one of these characters: ...
• 1,017
3k views

Output a random value from the last 16 values outputted

Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted. After the same item is printed 16 times in a ...
• 12.7k
3k views

Create a bingo card generator

Bingo Bingo is a numbers game where players match randomly drawn numbers to the numbers on their cards. Each bingo card is a square grid with 25 spaces, and the columns of the grid are labeled with ...
• 46.4k
2k views

Salacious Bacon Tripod

In a certain chatroom, we like making acronym jokes about the build tool we use called sbt. While it usually stands for "Scala Build Tool", we aim to come up with all sorts of meanings, such ...
• 33.6k
2k views

Implement a bag without replacement

Intro The Tetris Guidelines specify what RNG is needed for the piece selection to be called a Tetris game, called the Random Generator. Yes, that's the actual name ("Random Generator"). In ...
• 9,776
672 views

CGAC2022 Day 19: I Made It Out Of Clay

Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Happy Hanukkah! A beloved Hanukkah tradition for many, the game of Dreidel (s'vivon in Hebrew) is a betting game (...
• 1,585
3k views

Totally random Catan number distributions

I like to play (The Settlers of) Catan on Board Game Arena with totally random number tokens. These tokens determine the production rate of the terrain tiles beneath: There are 18 number tokens, two ...
• 3,807
352 views

Sample from the discrete triangular distribution

Given an integer n >= 1 as input, output a sample from the discrete triangular distribution over the integers k, for ...
• 3,829
2k views

Generate a Tiefling's Traits

A Tiefling is a character race, from Dungeons and Dragons, that has this list of possible traits: small horns fangs or sharp teeth a forked tongue catlike eyes six fingers on each hand goat-like legs ...
• 1,500
5k views

Super Mario 64 RNG

Introduction Super Mario 64 has a heavily overcomplicated RNG, ably explained here by Pannenkoek. I thought it might be interesting to implement it. Challenge Implement the RNG function, except for ...
• 1,787
4k views

What's the best die to roll?

The "standard" polyhedral game dice have 4, 6, 8, 10, 12 and 20 sides. (Yes, I know that there are two 10-sided dice which together make a d100, but we're ignoring that right now.) If I want ...
• 98.8k
4k views

Apartment Building

Draw an "apartment" building according to the specifications below. Basic Rules Take, as input, the number of floors of the building. Return a building with that many floors meeting the ...
• 1,357
377 views

Random Pixels Image Compression

Challenge: Given an integer $n$, guaranteed to be $\geq2$ and a power of 2, we are going to draw multiply boards either side-by-side or below one another, where the first has dimensions of $n$ ...
• 128k
415 views

Split given integer into a given number of integers, each within given bounds

Input variables: (Names are just examples, they don't need to be named like this) GrandTotal - integer to divide SplitCount - ...
866 views

Sniff out biased random permutations

The brilliant engineers at <enter company you love to hate> have struck again. This time they've "revolutionised" the generation of random permutations. "Every great invention is ...
• 16.7k
3k views

Shuffle an array, a little bit

Given some input array a = [a1, a2, ..., an] and a positive integer k, shuffle the input array ...
• 43.8k
2k views

Randomly Rounding

Input a decimal number and round it to an integer, randomly rounding up or down with a probability based on its fractional part, so the expected value of the output equals to the input value. If ...
• 34.9k
2k views

Random Point from a 2D Donut Distribution

A donut distribution (for lack of a better term) is a random distribution of points in a 2-dimensional plane, forming a donut-like shape. The distribution is defined by two parameters: the radius <...
• 7,324
3k views

Output a random unary string

Your task is simple: output the letter x a random number of times. Every possible length of xs must have a non-zero probability ...
• 23.9k
347 views

Busy beaver in a coin

$BB$ is the busy beaver function, an uncomputable function. Write a program which when given an integer $n$ as input, will output $BB(n)$, with at least $\frac 2 3$ probability. You can do ...
• 24.5k
918 views

Shuffle a subsequence

Thanks to rak1507 for the suggestion "Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. Uniform ...
2k views

Schrödinger's cat program [closed]

Sandbox Your challenge is to write a program that when first run, will do one of the actions below at random with equal chances of both: A cat program A standard cat program: read everything from <...
• 833
355 views

Repeat average‎

Background It was a normal presentation that I were in as a audience, until the presenter gave a math problem about repeat taking 2 number out of a list a replacing them with average, claiming that ...
• 1,807
428 views

Joe Mama or Joe Biden [duplicate]

Your task Randomly pick and print "Joe Mama" or "Joe Biden" in as little bytes as possible. Rules No trailing lines, spaces, or anything else weird like that No election fraud! ...
694 views

Simulate weathering of a rock

Inspired by my geography class, Sandboxed Simulate weathering / erosion. Input Input will be given as a string of any 2 characters (or see below) you like in the shape of the rock (here i use spaces ...
• 1,655
3k views

Randomly capitalize half of a string

Given string s of even length as input, randomly capitalize exactly half of the letters. You can assume the input will always be a non-zero, even length You can ...
• 11.6k
176 views

Print random characters indefinitely [duplicate]

Task Continuously print a random character (a-z, A-Z, 0-9) not separated by a newline (\n). Expected output ...
2k views

Given a number $n ≥ 2$, a blackbox function $f$ that takes no arguments and returns a random integer in the range 0...n-1 inclusive, and a number $m ≥ n$, your challenge is to generate a random ...
• 38.8k
3k views

Make me a shape

The game shapez.io has a huge variety of shapes you can produce, such as: Each shape has a unique short code, for example the above is CrWbScRu. This means, going ...
• 38.8k
4k views

Obfuscate my ><>

><>, or Fish, is a two-dimensional esoteric programming language where the instruction pointer (IP) toroidally moves around the codebox, wrapping when it hits an edge. ><> has four ...
• 38.8k
3k views

Make an array of random 128 bit integers

Given an input value $n$, construct an array of $n$ random 128 bit (unsigned) integers. The integers should be uniformly random. Your code can use any in built random number generation function ...
3k views

Roll up a D&D character, with options

I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average). Typically, a character's stats are created by ...
• 159
2k views

Generate a British numberplate

Modern British number plates (a.k.a. registration marks or license plates) use the format AANNXXX where AA is a "DVLA ...
• 23.9k
594 views

Bring my memories about Geronimo Stilton back

If you have read in your childhood a Geronimo Stilton's book, I am sure that you remember the style of the text, sometimes the words were decorated for making the act of reading more funny for kids: ...
• 1,336
2k views

Random Move 2x2 Scrambling

A simple way to scramble a 2x2x2 Rubik's cube is to make a sequence random moves. This is not how official scrambles are done, but can get pretty close to a uniform distribution of all possible ...
• 12.1k
2k views

Write a program with infinite expected output

Write a program that halts producing a random finite numerical output with probability 1. The expected value of the outputs of the program must be infinite. For physical limits, you can assume your ...
• 24.5k
13k views

Implement Minceraft

Introduction The game Minecraft has a 1 in 10000 chance of showing "Minceraft" instead of "Minecraft" on the title screen. Your challenge Your challenge is to code a function or ...
• 38.8k
Given a positive input $n$, output a random pair of primes whose difference is $n$. It's fine if there's another prime between them. Every pair should possibly appear and the program should have ...