Questions tagged [random]
Tasks involving random numbers and/or output.
345
questions
-3
votes
1
answer
202
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 ...
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 ...
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 ...
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 ...
5
votes
4
answers
807
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 ...
13
votes
9
answers
936
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. ...
13
votes
11
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: ...
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 ...
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 ...
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 ...
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 ...
11
votes
5
answers
648
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 (...
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 ...
9
votes
9
answers
336
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 ...
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
...
19
votes
9
answers
4k
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 ...
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 ...
15
votes
21
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 ...
8
votes
5
answers
356
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\$ ...
3
votes
7
answers
414
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 - ...
14
votes
3
answers
862
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 ...
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 ...
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 ...
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 <...
38
votes
54
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 ...
7
votes
1
answer
333
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 ...
16
votes
17
answers
905
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 ...
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 <...
8
votes
12
answers
354
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 ...
-9
votes
12
answers
414
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! ...
15
votes
4
answers
689
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 ...
25
votes
36
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 ...
3
votes
0
answers
171
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
...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
12
votes
2
answers
460
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: ...
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 ...
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 ...
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 ...
7
votes
10
answers
955
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 ...
13
votes
14
answers
2k
views
Verify the inequality!
Left in sandbox for at least 3 days.
I want to verify if this inequality is true:
for \$n\geq4\$, if \$a_1,a_2,a_3,\dots,a_n\in R_+\cup\{0\}\$ and \$\sum_{i=1}^na_i=1\$, then \$a_1a_2+a_2a_3+a_3a_4+\...
9
votes
18
answers
1k
views
Make a bottom up poem
Based on the "Pretty Ugly" poem.
Input consists of a number of stanzas (positive integer), and four arrays/lists of strings, called the "negatives", "negations", "...
43
votes
77
answers
5k
views
Print random integers until 0
You are to write a program which generates random integers between \$0\$ and \$99\$ inclusive, outputting each integer in turn, until \$0\$ is generated. You may choose which single-order random ...
2
votes
17
answers
643
views
Implement Smokey's !!/coffee command. (Part 2)
Like the previous SmokeDetector challenge? This one is for you too ;)
Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat.
What to implement
...
18
votes
15
answers
2k
views
Implement Smokey's !!/alive command
Note: SmokeDetector is a bot that detects spam and offensive posts on the network and posts alerts to chat.
What to implement
Smokey's !!/alive command uniformly ...
18
votes
23
answers
2k
views
Create an Accurate How-To Article
Here is an easy-intermediate challenge for anyone interested!
What is that?
A thing me and brother do a bit too often is this:
One of us has a problem and asks the other to explain how to do certain ...