Questions tagged [random]

Tasks involving random numbers and/or output.

Filter by
Sorted by
Tagged with
16 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 ...
user avatar
23 votes
18 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 ...
user avatar
  • 89.4k
16 votes
21 answers
2k 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 ...
user avatar
  • 1,298
8 votes
6 answers
268 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\$ ...
user avatar
3 votes
7 answers
385 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 - ...
user avatar
14 votes
3 answers
843 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 ...
user avatar
  • 8,060
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 ...
user avatar
  • 43.1k
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 ...
user avatar
  • 30.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 <...
user avatar
  • 6,498
35 votes
48 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 ...
user avatar
  • 22.2k
7 votes
1 answer
223 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 ...
user avatar
  • 12.9k
16 votes
16 answers
834 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 ...
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 <...
user avatar
8 votes
12 answers
339 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 ...
user avatar
  • 1,367
-8 votes
12 answers
356 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! ...
user avatar
  • 11
15 votes
4 answers
673 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 ...
user avatar
  • 1,614
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 ...
user avatar
  • 11.2k
3 votes
0 answers
149 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 ...
user avatar
20 votes
18 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 ...
user avatar
  • 31.5k
19 votes
16 answers
2k 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 ...
user avatar
  • 31.5k
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 ...
user avatar
  • 31.5k
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 ...
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 ...
user avatar
  • 22.2k
10 votes
2 answers
326 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 was decorated for making the act of reading more funny for kids, ...
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 ...
user avatar
  • 11.2k
13 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 ...
user avatar
  • 12.9k
59 votes
78 answers
12k 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 ...
user avatar
  • 31.5k
7 votes
10 answers
930 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 ...
user avatar
  • 12.9k
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+\...
user avatar
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", "...
user avatar
  • 191
41 votes
72 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 ...
user avatar
2 votes
17 answers
625 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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 2,619
31 votes
26 answers
3k views

Implement the random Fibonacci sequence

The random Fibonacci sequence is defined as follows: $$ f_n = \begin{cases} f_{n-1}+f_{n-2} \text{ with probability } 1/2 \\ f_{n-1}-f_{n-2} \text{ with probability } 1/2 \\ \end{cases} $$ $$ f_1 = ...
user avatar
32 votes
12 answers
2k views

Implement Entombed's lookup table

Background Entombed is an Atari 2600 game released in 1982, with the goal of navigating through a continuous mirrored maze as it scrolls upwards. In recent times, the game has been subject to research ...
user avatar
  • 1,658
32 votes
28 answers
3k views

Implement the Zundoko Kiyoshi function

Background The Zundoko Kiyoshi function originates from this tweet by kumiromilk. Translated from Japanese, it reads roughly as follows: The test for my Java lecture had a problem that said "...
user avatar
  • 1,658
7 votes
15 answers
1k views

Russian Roulette, varying chances [duplicate]

Russian roulette It's Russian roulette! The rules are simple. Shoot a revolver with n slots for bullets and one round inside at your head and you might not die! ...
user avatar
  • 1,430
2 votes
1 answer
127 views

Code golfing my guess the number game with feedback in NS-HUBASIC - Can it be code golfed any further?

The player has to keep guessing a number from 1 to 10 until they guess the correct number to win the game. If they make an incorrect guess, they're told if their guess was too low or too high. Each ...
user avatar
25 votes
7 answers
2k views

Where to point a low-orbit ion cannon (asking for a friend)

Challenge Premise Bob lost1 Alice's precious grand piano. Big mistake. Alice has now stolen Bob's low-orbit ion cannon. Alice refuses to just make up with Bob, so let's help her give him a light ...
user avatar
16 votes
58 answers
5k views

Make your code error, but only sometimes!

Your task is to create a program or function which randomly errors. Specifically, there must be a nonzero probability of erroring, but also a nonzero probability of running without error. An error is ...
user avatar
12 votes
6 answers
1k views

As close to flat as possible

Write a program or function that fulfills the following Scores less than 101 bytes under normal code-golf rules Takes no input1 and always outputs a single integer. Every integer is a possible output....
user avatar
  • 89.4k
4 votes
12 answers
462 views

Creating words by structure

Context As a conlanger, I am interested in creating a uniform, naturalistic language. One of the tricks is to create vocabulary according to certain structures of words. An example from English: In ...
user avatar
14 votes
14 answers
2k views

Simulate a random walk

Context In this challenge, a random walk is a stochastic process in which a particle at a position with integer coordinates (or a drunk man) moves at each integer time step (that is, at ...
user avatar
  • 13.8k
29 votes
7 answers
7k views

ASCII Pizza (no pineapple)

I like pizza! Task Given the radius of a pizza and a list of ingredients, create the corresponding ascii pizza! Example size 4 pizza with mozzarella cheese, olives and ham: ...
user avatar
  • 13.8k
2 votes
5 answers
425 views

Write some Random English

Your Goal: Given an odd integer input n greater than 1, generate a random English word of length n. An English word is one in ...
user avatar
1 vote
0 answers
195 views

What does the shortest pseudo-random algorithm look like? [closed]

After seeing some impossibly short solutions in this SE, I began to wonder what code someone could come up with to build a pseudo-random number generator. Now given that I am new to programming, I ...
user avatar
18 votes
10 answers
2k views

Spotify Shuffle (music playlist shuffle algorithm)

Background Perfect shuffle algorithms like Fisher-Yates shuffle don't produce great results when it comes to music playlist shuffling, because it often produces clusters of songs from the same album. ...
user avatar
  • 64.8k
14 votes
7 answers
570 views

Make a random drum loop

Do randomly generated drum loops sound good? A drum loop is a \$5\times 32\$ matrix \$A\$ of \$1\$s and \$0\$s such that \$A_{1,1}=A_{1,17}=A_{2,9}=A_{2,25}=1\$, for each \$i\$, the \$i\$th row has ...
user avatar

1
2 3 4 5
7