Tasks involving random numbers and/or output.

learn more… | top users | synonyms

7
votes
3answers
174 views

Natural Pi #1 - Sand

Goal Generate (N) random line segments of uniform length (l), check if they cross the equidistant (t) parallel lines. Simulation What are we simulating? Buffon's needle. Smooth out the sand in your ...
11
votes
1answer
141 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
337 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 y index (starting from the top left). For example: Input: 2 00 10 10 11 Input: 3 00 10 ...
25
votes
2answers
323 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: \ /\ / \ / / /\ /\ / \ \ / / /\ /\ \ / / ...
36
votes
17answers
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 sqrt(6 * N / #coprime). TL;DR These challenges are simulations of ...
9
votes
4answers
250 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 corners, starting from the top left. The squares should be side by side ...
8
votes
14answers
724 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 ...
21
votes
17answers
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 ...
12
votes
4answers
380 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. ...
40
votes
22answers
3k views

Sheffle tho vawols ureund!

Given an input string, output that string with all vowels a, e, i, o and u swapped at random between each other. For example, in the string this is a test, there are 4 vowels: [i, i, a, e]. A valid ...
35
votes
9answers
3k 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
7answers
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
960 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 ...
42
votes
50answers
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
503 views

Roll an ASCII die

In this code-golf challenge, you must output an ascii-art of a random die roll. like this: ________ /\ \ / \ 6 \ { 4 }-------} \ / 5 / \/_______/ Please note that: ...
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 ...
46
votes
21answers
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: = = = = = = = = == = == = == = ==== == ==== == === = = ====...
15
votes
12answers
1k views

Shamir's Secret Sharing

Given n (the number of players), t (the threshold value), and s (the secret), output the n secrets generated by Shamir's Secret Sharing algorithm. The Algorithm For the purposes of this challenge, ...
26
votes
9answers
1k 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
299 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
1k 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 file. Output n lines of the text ...
6
votes
5answers
250 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 ...
3
votes
6answers
231 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 input is the syllable types. ...
13
votes
18answers
739 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? ...
22
votes
3answers
782 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 ...
32
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
246 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
152 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 column contains the numbers 1-9 Each 3-...
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. ...
7
votes
4answers
450 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, ...
20
votes
3answers
665 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 ...
18
votes
1answer
357 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 Split the input file on newlines. Tear ...
16
votes
5answers
830 views

Is this number random?

I asked random.org for 128 random integers between 0 and 232 - 1. Since the random number generator was so eager to give the first 64 numbers first, they're obviously more random than the other 64. ...
8
votes
5answers
407 views

Word or near-word?

Write a program or function that given a string (or your language's equivalent), determine if the string is a word, or not, and output a truthy or falsy value. (This is not a duplicate of Is this ...
5
votes
3answers
308 views

Golf Me a Random Dubstep of the Day List

Aside of nursing my child, Vitsy, and dabbling in the art of code golf, I also am an avid dubstep fan, listening to all the new dubstep that Monstercat puts out as regularly as I can. I also share a ...
13
votes
4answers
354 views

Interpret the Pig series

Given an input of a Pig, SickPig, DeadPig, QuinePig, or DeafPig program, choose one of those "languages" randomly and interpret the input as that "language." First, randomly choose between one of the ...
11
votes
3answers
642 views

Help me Shut the Box

The inspiration for this challenge should be ridiculously obvious at the time of posting. The Task You must create a Shut the Box style program (not function, program). The basics of shut the box ...
6
votes
5answers
203 views

Sample win/loss data generator based on certain criteria

Lets say we have this existing data: Total - 10 Won - 7 Lost - 3 Longest Winning Streak - 5 Longest Losing Streak - 2 Now you need to write a function which generates an array of random boolean ...
15
votes
2answers
324 views

Exploding Cats!

Challenge You will be making a program/function that takes a string input of length n, and: Puts the kth char at the center of the space, where k = (n+1)/2. This will be the location of your ground ...
6
votes
0answers
150 views

MarGolf Meets Langton's Anthill

This is Markov. Markov's golf ball rolls around randomly. Markov's ball will hole however he strikes it. Markov is smart. Be like Markov. And this: is an anthill in Langton's backyard. The anthill ...
33
votes
28answers
5k views

Choose The Powerball Numbers!

Powerball is an American lottery that has recently gained attention because the current jackpot (as of January 11, 2016) is the largest lotto prize in history, at about $1.5 billion (USD). Powerball ...
10
votes
0answers
108 views

Chess-olition Derby

What could be more polar opposites than chess and demolition derby. You would think that no one who enjoys one would enjoy the other... until today. Rules The starting position is a standard chess ...
-4
votes
8answers
155 views

Use what you know: Your take on Diceware [duplicate]

If you're not familiar, Diceware is a method for creating passwords using an ordinary die from a pair of dice as a hardware random number generator. For the sake of fun, let's ignore anything about ...
25
votes
9answers
3k views

Map a random number to pi

A double precision representation of a decimal can only guarantee an accuracy of 15 decimal places, thus pi is approximated as: 3.141592653589793 You can see that the digit 3 is in positions 1, 10, ...
20
votes
15answers
1k views

The Random Walker Printer

Draw a program or function that will write to STDOUT n times (each for one step) a string that contains a dot . at the location of the walker. The program also needs to write a line every s seconds (...
19
votes
36answers
2k views

1/N probability

Because there are not enough simple code-golf challenges: Create an optionally unnamed program or function that, given (by any means) an integer 1 ≤ N ≤ 10000, outputs your language's True value with ...
31
votes
32answers
4k views

Russian Roulette, Reloaded

Let's play Russian Roulette! Normally, this would be a race to write the shortest MOD 6 program, but that's not very realistic, as the chance of winning decreases with each click. Here are the rules: ...
12
votes
7answers
379 views

D&D Skill Challenges

In Dungeons & Dragons, almost everything is decided by rolling a die. Typically, if the roll is greater than or equal to a specified value, your attempt at doing whatever you wanted to do succeeds,...