Questions tagged [random]

Tasks involving random numbers and/or output.

Filter by
Sorted by
Tagged with
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", "...
David Lui's user avatar
  • 191
45 votes
82 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 ...
caird coinheringaahin g's user avatar
2 votes
17 answers
647 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 ...
USERNAME GOES HERE's 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 ...
USERNAME GOES HERE's 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 ...
SunnyMoon's user avatar
  • 2,679
31 votes
27 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 = ...
caird coinheringaahin g's 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 ...
sporeball's user avatar
  • 1,656
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 "...
sporeball's user avatar
  • 1,656
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! ...
Wezl's user avatar
  • 1,478
2 votes
1 answer
133 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 ...
Niall Ward's 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 ...
subdermatoglyphic's user avatar
18 votes
65 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 ...
Rydwolf Programs's user avatar
17 votes
7 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....
Wheat Wizard's user avatar
  • 98.5k
4 votes
12 answers
477 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 ...
USERNAME GOES HERE's 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 ...
RGS's user avatar
  • 14.1k
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: ...
RGS's user avatar
  • 14.1k
12 votes
21 answers
943 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 ...
Mister SirCode's user avatar
1 vote
0 answers
220 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 ...
user91975's 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. ...
Bubbler's user avatar
  • 76k
14 votes
7 answers
596 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 ...
Dustin G. Mixon's user avatar
16 votes
15 answers
4k views

Drum fill generator

Create a program that generates a drum fill. Your program will output a pattern of L (left hand hits), 'R' (right hand hits), and ...
TMH's user avatar
  • 1,283
32 votes
24 answers
3k views

Generate a Nine-Ball Pool rack

Introduction Nine-Ball is a popular pool game played casually and as a competitive sport. There is one of each numbered ball, with the numbers 1 to 9. The game starts with all 9 of the balls in a ...
nihilazo's user avatar
  • 517
15 votes
10 answers
2k views

Random spanning tree of a rectangular grid

Significantly harder version of Spanning tree of a rectangular grid. Background A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of ...
Bubbler's user avatar
  • 76k
27 votes
11 answers
1k views

Random triple with uniform marginals

Output a random triple \$(x,y,z)\$ of real numbers such that \$x+y+z=\frac{3}{2}\$ Each of \$x,y,z\$, taken alone, is uniformly distributed from \$0\$ to \$1\$. Please explain in your answer what ...
xnor's user avatar
  • 145k
21 votes
11 answers
3k views

Advent calendar

Let's build an advent Calendar for this Christmas! Many Advent calendars for children take the form of a large rectangular card with numbered windows for each day of December starting from 1 ( ...
AZTECCO's user avatar
  • 10.8k
47 votes
28 answers
4k views

Simulate reproduction in a population of oozes

Reproductive strategy of oozes can be summarized as follows: o O 8 oo A population of oozes at generation N is described by a string, for example: ...
anatolyg's user avatar
  • 13.6k
3 votes
1 answer
425 views

Draw a fuzzy grid

Print the ASCII version of a random grid. ...
Moritz Schauer's user avatar
28 votes
33 answers
5k views

Make a haystack (with a needle)

(Essentially the inverse of Find the needle in the haystack) Given two tuples, (w, h) and (x, y), generate a haystack composed ...
AdmBorkBork's user avatar
  • 43.4k
29 votes
11 answers
4k views

Rational Number RNG

The Objective Build a random number generator whose range is \$\left[0,1\right) \cap \mathbb{Q} .\$ This is, build a random number generator that can produce any value that's: at least \$0 \,;\$ ...
Dannyu NDos's user avatar
  • 5,941
2 votes
15 answers
448 views

type in a random mess of capital letters [duplicate]

SOMe PEOPle lIkE tO TYpE iN A LoGiCAL MAnNER, WITh CapITals aT tHe bEGiNnIng Of ThE SENtENCE and smaLl LETTErS EVeRYWHErE eLsE. NOT Us. NOt Us. Your joB iS to tAkE A SenTEncE Of A LL SMAlL LeTTeRS, ...
SexyMan123's user avatar
25 votes
25 answers
4k views

Fill a bowl with alphabet soup

We seem to never get tired of alphabet-related challenges... The recipe Given a string of letters S, and two positive integers ...
Luis Mendo's user avatar
  • 104k
15 votes
13 answers
1k views

Interpret Volatile

Interpret Volatile Volatile is a stack-based esolang made by A_/a'_'/A that only has 8 instructions and is turing complete. However, it is also non-deterministic... meaning that programs don't always ...
lyxal's user avatar
  • 33.3k
44 votes
26 answers
10k views

Random point on a sphere

The Challenge Write a program or function that takes no input and outputs a 3-dimensional vector of length \$1\$ in a theoretically uniform random direction. This is equivalent to a random point on ...
Jitse's user avatar
  • 7,016
20 votes
15 answers
4k views

I multiply the source, you (probably) multiply the output!

Task The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (...
Mr. Xcoder's user avatar
  • 42.4k
34 votes
36 answers
8k views

The cat ate your input again!

Create a cat program, a.k.a a program that takes an input and prints it. ...Except, the program will randomly take characters away from your input and print that instead. Each character in the input ...
AndrewTheCodegolfer's user avatar
25 votes
35 answers
4k views

Write an interpreter for *

The task is simple. Write an interpreter for the language *. Here's a bigger link to the wiki. There are only three valid * programs: * Prints "Hello World" <...
TheOnlyMrCat's user avatar
  • 1,349
17 votes
14 answers
3k views

Generate a random point outside a given rectangle within a map

Introduction Given this visualization of a playing field: ...
jaaq's user avatar
  • 617
11 votes
1 answer
297 views

Compute my Sacred Geometry [closed]

In the tabletop RPG named Pathfinder, there is a feat that characters can take called Sacred Geometry, which allows a character who has it to buff their spells in exchange for doing some math: to use ...
nick012000's user avatar
25 votes
14 answers
3k views

Do you know your 'KVZ's?

Concept In what ways can you scramble the English alphabet so that it can still be sung to the tune Twinkle Twinkle Little Star without ruining the tune? Rules Swapping Let's just assume the ...
breadlord's user avatar
  • 361
30 votes
20 answers
3k views

Implement Homestuck's Catenative Doomsday Dice Cascader

Challenge I'm under attack by the larcenous Midnight Crew and I need to summon the Catenative Doomsday Dice Cascader in order to defend myself. Since I'm low on space, I need the code to be as short ...
Bazinga_9000's user avatar
27 votes
11 answers
4k views

Gambler's Fallacy Dice

The gambler's fallacy is a cognitive bias where we mistakenly expect things that have occurred often to be less likely to occur in the future and things that have not occurred in a while to be more ...
Beefster's user avatar
  • 9,931
17 votes
13 answers
1k views

Automatically anti-predictably assemble an alliterative aria

Thanks to @ComradeSparklePony for the title. This challenge should be very simple. You are given three lists. The first is a list of first names, in title case. The second is a list of adjectives, ...
Neil's user avatar
  • 170k
17 votes
6 answers
2k views

Generate a Pronounceable Nonsense Word \$n\$ syllables long

Your task is to generate a nonsense word that is reasonably pronounceable with the specified number of 'syllables'. Each time the program is run possibly results in a different nonsense word. ...
Beefster's user avatar
  • 9,931
36 votes
54 answers
6k views

Simulating Exploding Dice

Your task is to make a program that takes in an integer n > 1, and outputs the roll of a single n-sided die. However, this ...
Riker's user avatar
  • 7,840
31 votes
23 answers
3k views

Make it rain characters

Inspired by this chat mini-challenge. Given a string as input (ASCII printable characters only), output the string with the letters "raining" down. Each letter must be a random number of lines ...
AdmBorkBork's user avatar
  • 43.4k
5 votes
18 answers
6k views

To string or not to string

Given an input string, output at random the unique combinations with repetition of the characters in the input string, from length 1 up to the length of the input string, with an equal chance of each ...
Flog Edoc's user avatar
  • 101
18 votes
24 answers
6k views

ssTTsSTtRrriinInnnnNNNIiinngg

Challenge For each character of the string except for the last one, do the following: Output the current character. Followed by randomly outputting from the following list a random number of times ...
MilkyWay90's user avatar
  • 2,722
11 votes
11 answers
670 views

Generate a Baseball Pitch String

Goal Write a program or function that takes a positive integer n and randomly generate a legal series of pitches (henceforth called a Pitch string) of length ...
Veskah's user avatar
  • 4,110
11 votes
8 answers
2k views

Left Center Right (LCR) code golf

At a party, I was introduced to the game LCR. Now it's not a great game as there's no skill but only random chance. But it got me thinking, I could code this, and I made a quick program in R to model ...
CT Hall's user avatar
  • 611
57 votes
49 answers
11k views

A game of dice, but avoid number 6

Tournament over! The tournament is now over! The final simulation was run during the night, a total of \$3*10^8\$ games. The winner is Christian Sievers with his bot OptFor2X. Christian Sievers also ...
maxb's user avatar
  • 6,887

1
2
3 4 5
7