Stack Exchange Network

Stack Exchange network consists of 175 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.

22
votes
9answers
881 views

<(“<) Bird Dancer (>”)>

Your bird has been itching for some exercise and is sick of being stuck in static positions all the time. Write a program that will show a randomly dancing ascii bird, updating every 100ms*n or 200ms*...
22
votes
6answers
1k views

Animate tacky light decorations

This challenge is in honor of the tacky Christmas lights at my in laws' house. The challenge is to create a graphical output showing the decoration in "real time". The video (gif or other format) ...
20
votes
17answers
904 views

Random Pixel Poking

Your task is simple: write a program that will replace random pixels in a black 16px * 8px rectangle (width by height) with a white pixel. The holes must be uniformly random, and you should output ...
34
votes
29answers
2k views

Crazy 8s Code Golf

Create a program that prints all whole numbers inclusively between an interval (a, b), and replaces multiples of 8 in the sequence with random (uniformly ...
30
votes
21answers
2k views

Generate a random derangement

Challenge description A "derangement" of a sequence is a permutation where no element appears in its original position. For example ECABD is a derangement of ...
11
votes
10answers
516 views

This cat has bugs? Really?

Challenge: Read input (within visible ASCII range) and output with a few modifications: In each set of 10 characters of the input randomly (50/50): replace one character* (with a random** one ...
14
votes
7answers
812 views

It's almost Christmas!

Because of this, families from all over the world are building Christmas trees. But this normal tree can get boring after a while, so let's make an ASCII tree! Leafs are represented by ...
16
votes
2answers
417 views

Ways of specifying random generation in challenges

Note: As per consensus on Meta, challenge-writing questions are on topic here. In light of this "thing to avoid when writing challenges", I started to think about challenges involving random ...
4
votes
1answer
336 views

Labyrinth Polyglot [closed]

Create a program that can create a randomly arranged maze (The path of the maze changes each time) with exactly 1 exit and one enterance and a minimum size of 8x4 and max size of 32x32, with the exact ...
23
votes
16answers
1k views

Shuffle a ragged array

A ragged array is an array where each element is an array of unknown number of positive integers. For example, the following are ragged arrays: ...
80
votes
103answers
16k views

Shortest code to produce non-deterministic output

You need to produce output that is non-deterministic. In this case, this will be defined to mean that the output will not always be the same result. Rules: A pseudo-random number generator that ...
15
votes
21answers
2k views

Generate a cipher

Generate a cipher given a number and string Your task is simple. Given a string s and a number 0 <= n <= 9 as inputs, ...
57
votes
27answers
6k views

Cracking in progress

Remember those brute-force programs to crack password that show every combination they are trying? More precisely, at one point, the n first characters are fixed (they have been guessed successfully), ...
19
votes
6answers
1k views

Sample a random non-decreasing sequence

Input: Two integers n and k given in any form that is convenient for your code Output A random non-decreasing sequence of k integers, each in the range 1 to n. The sample should be chosen uniformly ...
27
votes
1answer
754 views

Who's that PRNG?

Given a sequence of 625 32-bit unsigned integers (that is, in the range [0, 2**32)), output which of the following pseudorandom number generators generated the ...
-5
votes
4answers
241 views

Generate a random digit! [closed]

Your task is to generate a random digit following these steps: First, generate 10 random digits to make a binary number, 50% 0, and 50% 1: 010011001 If it is ...
9
votes
3answers
511 views

Natural Pi #1 - Sand

Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (...
12
votes
1answer
213 views

Randomized Pumpkin Patch

I was walking through a pumpkin patch the other day for a birthday party, and noticed the pumpkin vines making a nifty pattern, with whirls, loops, and offshoots. We're going to simulate that here ...
9
votes
7answers
424 views

Fill in the grid randomly

Given positive integer n < 10, create a 2 dimensional matrix where each location is filled with its x and ...
27
votes
2answers
371 views

Hurricane Matthew and the Lightning Bolts

Challenge Inspired by this challenge and the nasty Hurricane Matthew, we will be generating some lightning bolts dynamically. n = 15: ...
39
votes
22answers
3k views

Natural Pi #0 - Rock

Goal Create a program/function that takes an input N, check if N random pairs of integers are relatively prime, and returns <...
9
votes
4answers
274 views

Produce n n-squares of integers with rotating *'s in consecuitive corners

The objective is to produce output of n squares (nxn) of random integers (0-9) with a moving * that rotates clockwise around the ...
9
votes
15answers
902 views

Shuffle a mapping

We define a map as a set of key-value pairs. For this challenge, you need to take each of the values and assign them to a randomly chosen key. You must randomly shuffle the values, and output the ...
23
votes
19answers
3k views

Faux Source Code

Output one random character for each character of source code (as illustrated below). The probability of each character is its frequency in the original source code. Thus the output will be fake ...
18
votes
8answers
862 views

Minesweeper At Work

Everyone knows the old minesweeper game that shipped with Windows XP. It's a simple grid with a 9x9 matrix of cells containing either a number (indicating how many mines are adjacent to it) or a mine. ...
42
votes
26answers
3k views

Sheffle tho vawols ureund!

Given an input string, output that string with all vowels a, e, i, ...
35
votes
9answers
4k views

Quixels - Quantum Pixels

Introduction A quixel is a quantum pixel. Similar to a classical pixel, it is represented with 3 integer values (Red, Green, Blue). However, quixels are in a super position of these 3 states instead ...
16
votes
11answers
2k views

Randomly Misspell a Word

Inspired by this CR question (please don't kill me for browsing CR) Spec The probabilities of misspelling a word are: 1/3 of the time don't change the output 1/3 of the time remove a random ...
13
votes
19answers
1k views

Implement this key cipher

Implement this key cipher Goal Use the algorithm (explained in the Algorithm section) to implement a certain cipher. The program must read input from STDIN or the closest available equivalent, use ...
47
votes
54answers
4k views

Random Golf of the Day #7: A distinctly random character

About the Series This is a guest entry for the Random Golf of the Day series. First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all....
16
votes
6answers
923 views

Roll an ASCII die

In this code-golf challenge, you must output an ascii-art of a random die roll. like this: ...
16
votes
12answers
3k views

Simulate a sock drawer

Background I have a collection of "weekday socks", which are seven pairs of socks labeled by the days of the week. When I wash my socks, they end up in a pile, and I must arrange them into the ...
52
votes
24answers
4k views

Do X without Y​

Usually, it is said that "Doing X without Y" can be a trap to beginners writing challenges (source). However, I am cocky and think that I can definitely make an X without any Ys. Randomly. Oh yes, ...
24
votes
24answers
3k views

Illustrate music beats

You know—they look like this: source The goal is to draw a music beats illustration like the following: ...
17
votes
12answers
2k views

Shamir's Secret Sharing

Given n (the number of players), t (the threshold value), and s (the secret), output the <...
31
votes
11answers
2k views

Generate a “GitHub” Avatar

Background / Description Note: as @HelkaHomba points out, the actual GitHub identicons are not actually random but based on the hash of a username The default GitHub avatar is a 5x5-pixel image. A ...
7
votes
2answers
447 views

Generate ASCII TetraVex

TetraVex is a tile-based edge-matching game that was originally coded by Scott Ferguson for the Microsoft Entertainment Pack 3 back in 1990. The game consists of a grid upon which square tiles are ...
16
votes
10answers
2k views

Read n random lines from a potentially huge file

This challenge is about reading random lines from a potentially huge file without reading the whole file into memory. Input An integer n and the name of a text ...
10
votes
8answers
457 views

Golf the K-means algorithm

K-means is a standard unsupervised clustering algorithm, which, given a set of "points" and a number of clusters K, will assign each "point" to one of K clusters. Pseudo-Code of K-means Note that ...
6
votes
7answers
679 views

Build a word generator!

Your task is to create a program/function to replicate this word generator. Details Your program/function take two input. One input is the categories. The other ...
13
votes
21answers
865 views

Run through an array

We all often hear the idiom "walk through the array" to mean "map the function over the following array". However, I need it done (now!), so I want you to run through the array. How do I run? ...
23
votes
3answers
887 views

Draw a random hexa-glyph

The above image is called a hexa-glyph. Hexa-glyphs are some cool patterns I made up while doodling during my DiffEq class. Here's how you make one: Consider the following set of points, shaped ...
31
votes
27answers
5k views

Passwordify the string

Your challenge is to passwordify the string! What is passwordifying, you ask? Take a string as input. This string will only contain uppercase letters, lowercase letters, digits, and spaces. You ...
6
votes
1answer
616 views

Print out a shape in printable ASCII art based on a specific number of sides provided by the user

The Challenge: Just as the title says, your challenge is to use the printable ASCII characters to create a program that prints out a random polygon in the terminal based on the number of sides, n ...
16
votes
24answers
2k views

Random array without repetition

I was answering one challenge here and this task was part of the challenge. I've got a 73 bytes solution in javascript. But I think it is too much for a simple thing. Challenge Given as input two ...
7
votes
1answer
333 views

Create a diagonal sudoku board

A Diagonal Sudoku board is a special case of Latin squares. It has the following properties: The board is a 9-by-9 matrix Each row contains the numbers 1-9 Each ...
16
votes
10answers
2k views

Creating a falling ball map

Introduction For the ones who never heard of this game before. You are playing a ball which needs to survive as long as possible. This is done by moving to the left or right, going to the holes. ...
9
votes
4answers
1k views

Naïve Markov Chain Word Generation

There are many ways to generate random words. You can take random syllables from a set, you can use n-tuples, probably neural networks (what can't they do?), alternating between consonants and vowels, ...
21
votes
3answers
739 views

Randomize the test

I'm a teacher, and in a few days I have to give my students a test. Now, I'm always worried about my loveliest students being hurt by the least loveliest ones when they cheat, so I want to randomize ...
20
votes
1answer
526 views

The puppy command

The puppy utility takes a filename as input, and does exactly what you would expect a puppy to do: it shreds it! How to shred Rip out the pages with your teeth ...