Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [random]

Tasks involving random numbers and/or output.

8
votes
3answers
230 views

Generate an RSA key pair

Given a positive integer \$N >= 4\$, output an RSA key pair (both the private and the public key) whose key length is \$N\$ bits. The RSA key generation algorithm is as follows: Choose an \$N\$-...
5
votes
29answers
1k views

Numbers Manipulation challenge

Use any programming language to generate two random digits between 1 and 9 (including both). Then your program should display: in the first line: the first random digit, in the second line: the ...
17
votes
7answers
2k views

Blind Random Sort

Here's a pretty common pattern for sorting algorithms: ...
16
votes
18answers
4k views

Simplistic Lava Lamp

Introduction: I think everyone knows what a Lava Lamp is, but in case they do not: (Image source) They're basically glass tubes that contain wax in a translucent liquid. The bottom part is heated ...
9
votes
3answers
290 views

Shared Birthday Party

An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the ...
29
votes
70answers
8k views

Randomizing until 0

Challenge Sandbox post Given a positive integer (K) Output a uniformly-random integer (Y) between ...
12
votes
12answers
2k views

Draw a distribution diagram!

Challenge You are given three integers as input - min_value, max_value, sample_size, that you can pass to your answer as either array or several parameters. Your ...
13
votes
12answers
1k views

Fun with strings and numbers

Here's a programming puzzle for you: Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]]...
30
votes
15answers
6k views

What surrounds my Minesweeper tile?

Minesweeper is a puzzle game where mines are hidden around a board of nondescript tiles with the goal of identifying the location of all mines. Clicking on a mine loses the game, but clicking on any ...
46
votes
44answers
14k views

99 bugs in the code

99 bugs in the code The adaption of "99 bottles of beer on the wall" for computer science where the bugs increase instead of the bottles decreasing is often re-posted around the internet. Example T-...
0
votes
0answers
116 views

Validate Sudoku (N by N) [duplicate]

Challenge : Create a random (pseudo random) Sudoku board with dimension n x n Input : Given : ...
19
votes
7answers
1k views

Rolling Quine Dice

Create a program that outputs itself. However, if the source code is repeated n times (meaning to concatenate a copy of the source code to the end n-1 times), then there should be 1/n probability ...
25
votes
8answers
2k views

Random numbers with fixed sum

Your task is to write a program or a function that outputs n random numbers from interval [0,1] with fixed sum s. Input ...
11
votes
11answers
420 views

Drag Race Countdown

Challenge: In a hypothetical scenario, the countdown timer for a race has random intervals between the counts, to prevent premature starting, e.g. ...
8
votes
4answers
475 views

Bots playing a counting game

Introduction A childhood game designed to help children learn to count in french in Canadian schools is played as follows: Students go around the room counting up to 11 A number greater than 11 ...
9
votes
12answers
701 views

Asterisks viral

Given a positive integer N ("virality"), your program should create an ASCII-art drawing of a tree with two branches of length N extending downwards and/or rightwards from the top-left corner. The ...
23
votes
12answers
2k views

Drunkard's Journey Home

Drunkard's Journey Home In this challenge you are to write a program which simulates a drunkard stumbling his way home from the bar. Input: The input will be an adjacency matrix (representing a ...
16
votes
23answers
2k views

Factory workers

Challenge Factory workers are usually very hard-working. However, their work is now being commonly replaced with machines. You have to write a program that takes a number as input. It will print out ...
53
votes
102answers
13k views

Duck, duck, goose!

Remember the kids game, 'Duck, Duck, Goose'? No? Me neither. The challenge Print the word 'duck' on individual lines an indeterminate amount of times. Print the word 'goose'. Your program ends. The ...
4
votes
4answers
333 views

Generate a heap of boxes

(The text asks how many boxes there are in the picture) Now you are required to generate such a problem and its answer. Input an integer n (optionally) random ...
40
votes
21answers
5k views

EASY to memorize numbers

Numbers that are easy to remember yet theoretically not easily made Your challenge is to make a program/function in any language that generates uniformly random numbers that fit these criteria: ...
34
votes
32answers
6k views

Create a Magic 8 Ball

As a child, my friend had a magic 8 ball that we would ask questions to and see what the fate of that question was. Challenge Your challenge is to write a program (or function) that when run (or ...
38
votes
19answers
4k views

Create a solar system

Intro This is based on an actual problem I recently faced while making a computer game and I thought it would make for a nice round of code-golf. There are seven main spectral classes of star which ...
3
votes
1answer
250 views

Turn Your Program into a Snake! [duplicate]

...or "snakes but not too long". Inspired by this challenge and this comment. Task Write a program or a function that takes no input and outputs its own source code formatted as a snake according ...
29
votes
27answers
4k views

Code Golf: Your own horizontal pet ASCII snake

Very heavily inspired by this challenge Code Golf: Your own pet ASCII snake - I thought making it horizontal would add an extra layer of complexity. An example horizontal snake: ...
16
votes
11answers
2k views

Want to see a Magic Card Trick?

The first magic card trick I ever learned as a child was the following: Have 1 deck of cards where the pattern on the back is not vertically symmetric. Organize all cards to be facing one direction. ...
34
votes
48answers
10k views

Code Golf: Your own pet ASCII snake

So, I wrote myself a one-liner which printed out a snake on the console. It's a bit of fun, and I wondered how I might condense my code... Here's a (short) example output: ...
6
votes
5answers
211 views

Riffle shuffle a string - Robbers

Cops post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle ...
8
votes
9answers
406 views

Riffle shuffle a string - Cops

Robbers post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle ...
30
votes
3answers
449 views

The Drunken Typist

Background A typist comes home wfter some riugh drinkinh and realizes thag an importsnt letter still needs to be wtitten. To make sure he vets the text correct, he writes the text character bh ...
16
votes
9answers
638 views

XKCD Calendar Facts

Inspiration. Posted with permission. Print one of the possible XKCD calendar "facts": You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (...
22
votes
24answers
2k views

Sample the Pareto Distribution

The Pareto Distribution is a probability distribution that comes up a lot in nature. It has lots of special properties, such as an infinite mean. In this challenge, you will output a number sampled ...
12
votes
2answers
336 views

Play a game of Dice Cricket

Dice Cricket is a game I was introduced to as a child and have used as a way to pass time for years since. I couldn't find a Wikipedia page so I'll explain the rules below. Dice Cricket Rules ...
35
votes
52answers
5k views

Random Capitalization

The Task Your task is to create a program or a function that, given an input, outputs the input text with random letters capitalized, while keeping already capitalized letters capitalized. Every ...
17
votes
3answers
693 views

Draw 'Til You Drop

In Dungeons & Dragons 5th edition (as well as most other editions), there exists a magic item called the Deck of Many Things. It is an incredibly powerful item, as the cards all have very strong ...
30
votes
33answers
7k views

That's a lot of monkeys

The infinite monkey theorem states that, given infinite time, a machine sending an endless stream of random characters will always type any given text. That sounds to me like a great idea for a ...
28
votes
23answers
3k views

Basic sort, with annoying bug

Your input is a list/sequence/vector/array of 5-255 positive integers, not necessarily unique. You may assume whatever input format is most suitable, and that each integer (as well as the quantity of ...
13
votes
10answers
638 views

Deal an ASCII Deck

There's never really been a definitive ASCII-cards challenge AFAIK. So, using the following deck of ASCII cards: ...
13
votes
12answers
4k views

Name of Frankenstein's Monster

Introduction: Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through Frankenstein's wikipedia page, and came across the ...
7
votes
3answers
355 views

Generate random LTL Formulae [closed]

An LTL Formula l is defined by the following grammar (where <x> describes the non-terminal symbol x): ...
9
votes
7answers
468 views

Fill the steps (randomly)!

This is Hole-9 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here. Given a simple (rectangular, non-jagged) Boolean array (...
13
votes
1answer
417 views

Demolish a string!

Challenge Given a string input, output the demolished version of it. The Process ...
9
votes
4answers
390 views

Hidden sentences in the license plates

Introduction: Inspired by both Perfect License Plates and How many points does my license plate give? Just like in the challenges above, me and my little brother had a game of our own with license ...
19
votes
36answers
3k views

Randomly select from an array

This challenge is rather simple: You are given an array of positive (not including 0) integers, and have to select a random element from this array. But here's the twist: The probability of selecting ...
42
votes
23answers
8k views

Chaos is an ASCII ladder

You know nothing The things I do for "Chaos is a ladder" is a memorable line from the television series Game of Thrones. The purpose of this challenge is to build a ladder from chaos, in ASCII art. ...
8
votes
7answers
464 views

Generating Word Grids

Given input n, produce a word grid of size n, in as few bytes as possible. Details The number provided will always be odd. The ...
14
votes
2answers
671 views

Make a lost RNG

Lost is a 2-D programming language where the start position and direction of the ip are entirely random. This makes it very difficult to make deterministic Lost programs. However today we are not ...
7
votes
18answers
868 views

Is it a new highscore?

Challenge: In the language of your choice, write a program that generates a leaderboard with random scores and outputs it, then take a new score as input and check if it can be placed in the ...
16
votes
6answers
950 views

The Double Slit Experiment

A lazy physicist has the job to perform the double slit experiment. However, they are lazy and can't be bothered to set up all the equipment themselves and so are going to simulate the effects. They ...
26
votes
45answers
3k views

Randomly select a character, plinko-style

Let's see how good your language of choice is at selective randomness. Given 4 characters, A, B, ...