Questions tagged [random]

Tasks involving random numbers and/or output.

Filter by
Sorted by
Tagged with
3 votes
0 answers
27 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 ...
Wheat Wizard's user avatar
  • 98.6k
21 votes
38 answers
2k 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 ...
vengy's user avatar
  • 2,163
16 votes
21 answers
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 ...
vengy's user avatar
  • 2,163
1 vote
8 answers
288 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 = ...
vengy's user avatar
  • 2,163
5 votes
4 answers
493 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: ...
vengy's user avatar
  • 2,163
1 vote
3 answers
289 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 ...
Shahnazi2002's user avatar
-3 votes
1 answer
232 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 ...
paki eng's user avatar
  • 175
18 votes
22 answers
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 ...
The Empty String Photographer's user avatar
17 votes
18 answers
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 ...
Command Master's user avatar
15 votes
10 answers
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 ...
KeizerHarm's user avatar
  • 1,363
5 votes
4 answers
811 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 ...
CursorCoercer's user avatar
13 votes
9 answers
941 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. ...
math scat's user avatar
  • 9,228
15 votes
13 answers
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: ...
Peter's user avatar
  • 1,007
28 votes
32 answers
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 ...
mousetail's user avatar
  • 12.5k
13 votes
16 answers
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 ...
Stewie Griffin's user avatar
14 votes
13 answers
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 ...
lyxal's user avatar
  • 33.3k
24 votes
21 answers
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 ...
bigyihsuan's user avatar
  • 9,348
11 votes
5 answers
665 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 (...
AAM111's user avatar
  • 1,585
21 votes
10 answers
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 ...
Parcly Taxel's user avatar
  • 3,737
9 votes
9 answers
347 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 ...
user1502040's user avatar
  • 3,829
11 votes
15 answers
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 ...
AncientSwordRage's user avatar
19 votes
11 answers
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 ...
NoLongerBreathedIn's user avatar
24 votes
19 answers
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 ...
Wheat Wizard's user avatar
  • 98.6k
15 votes
22 answers
3k 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 ...
Romanp's user avatar
  • 1,357
8 votes
5 answers
371 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\$ ...
Kevin Cruijssen's user avatar
3 votes
7 answers
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 - ...
Isaac Reefman's user avatar
14 votes
3 answers
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 ...
loopy walt's user avatar
  • 16.7k
20 votes
13 answers
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 ...
flawr's user avatar
  • 43.8k
21 votes
26 answers
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 ...
tsh's user avatar
  • 34.7k
17 votes
12 answers
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 <...
Jitse's user avatar
  • 7,016
38 votes
58 answers
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 ...
pxeger's user avatar
  • 23.7k
7 votes
1 answer
343 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 ...
l4m2's user avatar
  • 23.9k
16 votes
17 answers
915 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 ...
caird coinheringaahin g's user avatar
19 votes
13 answers
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 <...
CreaZyp154's user avatar
8 votes
12 answers
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 ...
okie's user avatar
  • 1,807
-9 votes
12 answers
424 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! ...
Sidney's user avatar
  • 9
15 votes
4 answers
692 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 ...
zoomlogo's user avatar
  • 1,655
26 votes
41 answers
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 ...
Mayube's user avatar
  • 11.6k
3 votes
0 answers
173 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 ...
DisplayNameNotFound's user avatar
20 votes
21 answers
2k views

Adaptive randomisation

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 ...
emanresu A's user avatar
  • 37.8k
20 votes
20 answers
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 ...
emanresu A's user avatar
  • 37.8k
23 votes
8 answers
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 ...
emanresu A's user avatar
  • 37.8k
15 votes
27 answers
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 ...
user avatar
15 votes
15 answers
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 ...
darthbeep's user avatar
  • 159
12 votes
8 answers
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 ...
pxeger's user avatar
  • 23.7k
12 votes
2 answers
549 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: ...
ZeroCodeException's user avatar
24 votes
18 answers
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 ...
qwr's user avatar
  • 12.1k
12 votes
17 answers
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 ...
l4m2's user avatar
  • 23.9k
61 votes
91 answers
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 ...
emanresu A's user avatar
  • 37.8k
7 votes
10 answers
958 views

Random pair of primes

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 ...
l4m2's user avatar
  • 23.9k

1
2 3 4 5
8