Questions tagged [random]
Tasks involving random numbers and/or output.
359 questions
12
votes
3
answers
439
views
Fast sampling of special binary strings
We are going to define a simple little language. A word in this language is a binary string where the longest run of consecutive \$0\$s, is shorter than every (maximal) run of \$1\$s. So for example:
\...
33
votes
8
answers
4k
views
Rig The Lottery, but Don't Get Caught
Edit: Please note there is currently a vote to close this coding challenge due to a complaint that it may be technically violating a decade old rule for this site. There is currently a discussion in ...
14
votes
25
answers
2k
views
Draw X numbers from range Y
Inspired by this question
Task:
Given integers X and Y:
Randomly select an int in 1..Y (inclusive), X times. This selection is to be performed without replacement ...
32
votes
5
answers
4k
views
Roll a die in 3D
Simulate a roll of a fair die, and output the result in this ascii-art form:
...
21
votes
22
answers
2k
views
Randomly color the words
Inspired by this X post.
Write a program or function that takes a string as input and prints or otherwise renders the text with each word in a random color, e.g.:
The input will be a string of ...
13
votes
22
answers
2k
views
Three up to 800 & sum to 2048
(Flexibly) output 3 random integers such that:
Each number is 1 to 800 inclusive
Their sum is ...
14
votes
1
answer
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 ...
21
votes
38
answers
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 ...
16
votes
22
answers
3k
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 ...
1
vote
8
answers
397
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 = ...
5
votes
4
answers
592
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: ...
1
vote
3
answers
346
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 ...
-3
votes
1
answer
284
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 ...
21
votes
23
answers
4k
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 ...