Linked Questions

130
votes
515answers
40k views

Shortest infinite loop producing no output

Your task is to create the shortest infinite loop! The point of this challenge is to create an infinite loop producing no output, unlike its possible duplicate. The reason to this is because the code ...
82
votes
154answers
19k views

“99 Bottles of Beer”

Write a program that outputs the lyrics to 99 Bottles of Beer, in as few bytes as possible. Lyrics: ...
109
votes
79answers
24k views

Draw the national flag of Iceland

This year's UEFA Euro 2016 is over and besides a couple of negative headlines there has been a very positive surprise as well – the Iceland national football team. Let's draw their national flag. ...
46
votes
139answers
15k views

Output programming language name

Challenge: In the programming language of your choice, take no input and output your programming language's name. Fair enough, right? Restrictions: You can't use any character that is included in ...
43
votes
106answers
16k views

Is this number evil?

Introduction In number theory, a number is considered evil if there are an even number of 1's in its binary representation. In today's challenge, you will be identifying whether or not a given number ...
112
votes
32answers
17k views

Blink the CAPS LOCK

Most computer keyboards feature a small integrated LED light, indicating the current input mode, as controlled with the CAPS LOCK button. Your task is to blink it: Turn it on; Wait for 0.5 (+/-0.1) ...
103
votes
37answers
7k views

Source code ecological footprint

You've just been hired by a German car manufacturing company. Your first task, as an engineer, is to write a program that computes the ecological footprint of ASCII strings. The ecological footprint ...
40
votes
88answers
6k views

Print an alphabet wave

You are to print this exact text: ...
31
votes
97answers
5k views

Alphabet Staircase

The Challenge Your task is to create a program or function that outputs the following with no input: ...
29
votes
80answers
8k views
+50

Print 0 to 100 without 1-9 characters

Print 0 to 100 without using characters 1,2,3,4,5,6,7,8,9 in your code. Seperator of numbers can be comma, whitespace or newline. Shortest code wins.
48
votes
51answers
8k views

Blue duck, red duck, gray duck

So, last week I posted a challenge to play Duck, Duck, Goose. This lead to a number of Minnesotans commenting about their regional 'Gray duck' variation. So here's the rules: Using this list of ...
73
votes
34answers
11k views

Wait a minute – in less than ten seconds

Task Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half). The program/function must terminate within 10 seconds ...
46
votes
38answers
10k views

Retina or Trash?

We live in a wonderful age of technology where we can have beautifully detailed 8K screens on our TVs, and even 2K displays on our phones for our mobile browsing pleasure. We've come a long way in ...
31
votes
70answers
8k views

Randomizing until 0

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

Insist on an answer

At runtime, keep prompting for a line of input until the user inputs something (other than an empty newline), i.e. does not just press Enter or OK. Output or result is neither required nor prohibited. ...
42
votes
48answers
9k views

We had a question once which only failed on Sundays

Inspired by We had a unit test once which only failed on Sundays, write a program or function that does nothing but throw an error when it is Sunday, and exit gracefully on any other day. Rules: No ...
52
votes
32answers
9k views

Generate a mandelbrot fractal [closed]

Your task is to draw the mandelbrot set in ascii. It should look something like The complex number c lies in the mandelbrot set, when the sequence ...
47
votes
30answers
11k views

Pixel-art, episode 1: display Super Mario

it's a-me! Today's task is simple: write a program, or a function that displays the idle small Mario sprite, from Super Mario Bros, on NES, over a blue background. Any kind of entry is valid as long ...
27
votes
40answers
3k views

Making an acronym

Objective Your goal is to make a program that converts an input to its acronym. Your input is guaranteed to have only letters and spaces. The input will have exactly one space between words. You must ...
30
votes
27answers
7k views

Output a Super Mario Image

This is a problem on Luogu OJ. I decided to post it here because on Luogu OJ, many people, including me and my friend, are interested about how to solve this problem within the fewest characters. ...
30
votes
36answers
2k views

Sort the unique numbers in a multiplication table

Pretty simple challenge today: Write a program or function that takes in a positive integer N and prints or returns a sorted list of the unique numbers that appear in the multiplication table whose ...
30
votes
30answers
4k views

Make me a fake loader

Make a fake loader just like this : Parameters : Display loading (space) one of these cyclically-\|/ (space) (percentage ...
17
votes
46answers
2k views

IPv4 Integer Conversion Function

Write the shortest function to convert an IP address into it's integer representation and output it as an integer. To change an IPv4 address to it's integer representation, the following calculation ...
39
votes
26answers
2k views

ASCII clock with dot & comma time markers

Introduction Imagine that line of chars is in fact two rows. Upper row - dots - represents hours (24 hour system), while lower - commas - represents minutes. One character can represent hour, minute ...
41
votes
13answers
5k views

Advanced Code Golf - Write a small HTTP server

Your challenge is to write a code-golf HTTP server that accepts GET requests. It obviously doesn't have to be fully featured, but it must serve files from a directory. Rules: The HTTP server must ...
18
votes
27answers
2k views

Count Up, Replace, Repeat!

Definition Define the nth array of the CURR sequence as follows. Begin with the singleton array A = [n]. For each integer k in A, replace the entry k with k natural numbers, counting up from 1 to k. ...
18
votes
35answers
2k views

Recover the power from the prime power

It seems that many people would like to have this, so it's now a sequel to this challenge! Definition: a prime power is a natural number that can be expressed in the form pn where p is a prime and n ...
10
votes
62answers
1k views

Given an int input n, print out n*reversed(n)

Given an integer n, print out n * reversed(n) reversed(n) is the number you get when you <...
19
votes
34answers
3k views

Text compression

With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in ...
33
votes
15answers
3k views

An Ant on a Cube

An ant walks along the edges (not faces) of a wireframe cube. Each vertex it encounters presents it with a fork from which two new edges branch off. The ant chooses which way to turn -- ...
23
votes
22answers
2k views

Pad a jagged array to be square

Given a 2-dimensional jagged array and a fill value, pad the array in both dimensions with the fill value to ensure that it is square and not jagged (i.e., all rows are the same length, and that ...
19
votes
23answers
2k views

Insist on a new filename

At runtime, keep prompting for a line of input until the user input is not the name of an existing file or directory or other file system item, relative to the current working directory. Then return/...
27
votes
18answers
1k views

Right-align text

Your job is to take a string input and a number and align the string to the right, making the width of the text the number. When a line is too long, break it and put the rest on the next line, ...
12
votes
25answers
2k views

N-Dimensional Cartesian Product

Introduction The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some ...
12
votes
31answers
5k views

Print a string with vertical words

Your task is to take an input string of ascii characters and output the string as a series of vertical words separated by spaces. An example is shown below: Given the string: ...
17
votes
10answers
3k views

A Skittish Program

Objective You are to write a program that receives an integer n as input (from the command line), and embeds itself (the program) ...
9
votes
21answers
1k views

deRpiFy tHe sTriNg! [closed]

yOu wiLl bE giVen A sTriNg wHich cOnsiSts oF pRintAble asCii cHarActErs. yOu iTeraTe tHrougH thE sTrIng tHen chAnge rAndOM(uNifoRm, 50% cHanCe uPPercAse) lEtteRs to uPPercAse aNd eVerytHing ...
14
votes
14answers
1k views

Short Date into English Long Date

Convert short date format into English long date in as few bytes as possible. Input Input will be in the form of a string with format, yyyy-mm-dd, with zero padding ...
18
votes
5answers
1k views

Find a sequence in the binary digits of π

Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input ...
11
votes
9answers
1k views

What is this date format?

For Gregorian calendars, the date format varies from a country to another. There are three main formats recognized: YY-MM-DD (big-endian) ...
17
votes
6answers
2k 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 ...
13
votes
8answers
792 views

Line numbering - implement nl

Your task is to implement a program similar to the nl command-line tool from the GNU core utilities. Standard loopholes are banned. You may not use any built-in ...
10
votes
4answers
406 views

Expose nondeterminism resulting from the OS thread scheduler

As we all know, modern operating systems have thread schedulers that can pick different orders to schedule your threads based on internal logic which your code is not privy to. Normally you architect ...
7
votes
4answers
144 views

Tips for restricted source in zsh

Adapted from tips for restricted-source in Python Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the zsh language. While we already have a place to collect ...