Tasks involving random numbers and/or output.

learn more… | top users | synonyms

35
votes
18answers
2k 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, ...
22
votes
8answers
923 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
271 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
236 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
209 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
728 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? ...
16
votes
2answers
524 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
240 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
144 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 ...
16
votes
10answers
1k 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
387 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
656 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
327 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. ...
8
votes
5answers
393 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
300 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
311 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 ...
10
votes
3answers
630 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 ...
4
votes
3answers
111 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 ...
15
votes
2answers
309 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
145 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
102 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
151 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
375 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,...
46
votes
32answers
4k views

Alex-style Addition

Inspired by Alex's glorious Learn you an R for great good, we are going to humbly recreate Alex's "one true R program" -- but with a twist. Alex-style Addition works like this -- it has a 90% chance ...
17
votes
1answer
387 views

Random Golf of the Day #6: Roll a d20

About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
24
votes
3answers
2k views

Generating Brainf*** NOPs

Sometimes when writing brainfuck code, you feel the need to make it longer than needed to encourage debugging. You could do it by just plopping a >< in there, but what fun is that? You'll need ...
12
votes
10answers
1k views

Iterated Dice Rolling

Given an input n where 3 <= n <= 25, perform the following steps, starting with a single n-sided die (faces in the range [1, n], inclusive): Print the result of rolling the current n-sided ...
0
votes
3answers
176 views

Layout my tiles for me

I'm retiling my kitchen with different coloured tiles. In fact, it's going to have at least 2 colours - and 26 colours as a maximum. But, I'm fussy. I want this wall to look random, but sometimes ...
57
votes
4answers
1k views

Simulate the Universe!

One nice property of a Turing-complete language is that it can be used to write any program, up to and including the simulation of the entire Universe. Your job is to do exactly that: write a program ...
21
votes
1answer
351 views

Plumbing Random Paths

Write a program or function that takes in three integers, a width w, a height h, and a step count s. You will be drawing a non-self-intersecting random walk s steps long on a 5*w by 5*h pixel image ...
-4
votes
24answers
397 views

Generate 0 or 1 [closed]

Is this Q too easy to ask, or has it just never been thought of? Generate a random number, either 0 or 1 using a program You may use a pre-defined function. The code must be executable. (It can'...
10
votes
11answers
1k views

“i” have “i” chance of occuring

Design a random number generator where the i th number has i% chance of occurring for all 0 < i < 14. 0 should have exactly 9% chance of occurring. The seed for the generator should be the ...
5
votes
1answer
104 views

Roller coaster of numbers [duplicate]

Write a program that generates a sequence of numbers starting with zero and then 100 random integers between -9 and 9. That sequence will be displayed like a roller coaster. Any increasing number in ...
14
votes
19answers
865 views

Boo! A Halloween Code Golf Challenge

Write a program that takes an input string of length 2 or more characters and adds the string ~BOO!~ (that string has a leading and ending space) in a uniformly random spot in the string that is not ...
12
votes
6answers
415 views

Simulate a game of Craps

Craps is a fairly simple dice game often played in casinos. Even if you aren't a gambler (which I'm not), it's still a fairly interesting game. Here's the rules: At the start of a game of Craps there'...
17
votes
2answers
469 views

Generate Some Secure PINs

Inspired by this badly received migrated post. The head of security at your company is concerned about your PIN generating system after it gave him 12345. He also didn't really appreciate the ...
12
votes
3answers
262 views

Generate a Monotonic Function

Overview In this challenge, your task is to randomly generate a monotonic mathematical function between two sets. Input Your inputs are two positive integers s and n. After getting these inputs, ...
7
votes
12answers
1k views

Generate random UUID

I need a UUID. Your job is to generate one. The canonical UUID (Universally Unique IDentifier) is a 32-bit hexadecimal number with hyphens inserted in certain points.The program should output 32 hex ...
27
votes
30answers
3k views

Person of Interest

Background Person of Interest is a crime drama on CBS, and my favorite TV show, as of late. The show is about a man named Harold Finch, a billionaire programmer, and his partner John Reese, a ...
13
votes
15answers
2k views

Randomize points on a disc

I read about circles somewhere, and just now learned about discs (it's actually a pretty common concept) and thought about codegolf. Your task is to randomize a point/several points on a disc with ...