Linked Questions

424
votes
764answers
130k views

“Hello, World!”

So... uh... this is a bit embarrassing. But we don't have a plain "Hello, World!" challenge yet (despite having 35 variants tagged with hello-world, and counting). While this is not the most ...
582
votes
276answers
213k views

Produce the number 2014 without any numbers in your source code

Note to challenge writers as per meta consensus: This question was well-received when it was posted, but challenges like this, asking answerers to Do X without using Y are likely to be poorly ...
204
votes
337answers
45k views

Golf you a quine for great good!

Using your language of choice, golf a quine. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. No cheating -- that means ...
122
votes
479answers
36k 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 ...
149
votes
377answers
27k views

Implement a Truth-Machine

A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does: Gets a ...
386
votes
110answers
82k views

Most creative way to display 42

Douglas Adams was born on March 11, 1952, and died when he was just 49. In honor of this wonderful writer, I challenge you to display 42 in the most creative way possible. You could print it in the ...
189
votes
209answers
41k views

The Programming Language Quiz

Congratulations to Dennis who won both the cops' and the robbers' challenge! Calvin's Hobbies has already delivered on his promise and wrote this challenge for Dennis for winning the robbers' ...
151
votes
268answers
41k views

1, 2, Fizz, 4, Buzz

Introduction In our recent effort to collect catalogues of shortest solutions for standard programming exercises, here is PPCG's first ever vanilla FizzBuzz challenge. If you wish to see other ...
115
votes
239answers
27k views

Fibonacci function or sequence

The Fibonacci sequence is a sequence of numbers, where every number in the sequence is the sum of the two numbers preceding it. The first two numbers in the sequence are both 1. Here are the first ...
183
votes
144answers
17k views

What is the smallest positive base 10 integer that can be printed by a program shorter (in characters) than itself?

I think the question as above is clear, but just in case: Write a full program (not just a function) which prints a positive base 10 integer, optionally followed by a single newline. Qualifying ...
223
votes
75answers
75k views

Code that will only execute once

Goal The goal of this challenge is to write code that will execute once and only once. This means basically that it damages the program, script, or environment in some way. If rebooting the system ...
161
votes
127answers
31k views

Trick or Treat polyglot

Since Halloween is coming up I thought I might start a fun little code golf challenge! The challenge is quite simple. You have to write a program that outputs either ...
86
votes
262answers
15k views

Create output twice the length of the code

The Challenge Write a complete program that writes twice as many bytes to standard output as the length of the program. Rules The program must write ASCII characters to the standard output. The ...
84
votes
272answers
22k views

Print a 10 by 10 grid of asterisks

Background This is a standard textbook example to demonstrate for loops. This is one of the first programs I learnt when I started learning programming ~10 years ago. Task You are to print this ...
84
votes
264answers
16k views

Simple cat program

One of the most common standard tasks (especially when showcasing esoteric programming languages) is to implement a "cat program": read all of STDIN and print it to STDOUT. While this is named after ...
71
votes
186answers
13k views

Count up forever

Write a program that counts up forever, starting from one. Rules: Your program must log to STDOUT or an acceptable alternative, if ...
45
votes
189answers
13k views

Add two numbers

Input: Two integers. Preferably decimal integers, but other forms of numbers can be used. These can be given to the code in standard input, as arguments to the program or function, or as a list. ...
58
votes
137answers
11k views

Draw an asterisk triangle

Inspired by a task for programming 101 here's a task that hopefully isn't too easy or is a duplicate (kinda hard to search for things like this). Input: A positive integer ...
50
votes
126answers
8k views

Print all integers

Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: ...
64
votes
82answers
12k views

Golf all the 16 logic gates with 2 inputs and 1 output!

For example, the gate A and B is a logic gate with 2 inputs and 1 output. There are exactly 16 of them, because: each logic gate takes two inputs, which can be ...
76
votes
68answers
20k views

Shortest program that throws StackOverflow Error [closed]

Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError...
70
votes
76answers
6k views

No strings (or numbers) attached

If you like this, consider participating in: The Official Dyalog APL 2016 Year Game The monthly Dyalog APL 2017 Code Golf Challenge Make 12 snippets/expressions, in the same language, that result in ...
134
votes
28answers
11k views

Making Future Posts Runnable Online with Stack Snippets

Stack Snippets were recently added to PPCG! Reminiscent of JSFiddle, Stack Snippets allow HTML, CSS, and JavaScript to be run directly in posts! Here is a very simple Stack Snippet: ...
43
votes
67answers
6k views

Play a sound, any sound [closed]

Your program has to make the computer produce a sound, any sound. Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins. The ...
41
votes
68answers
6k views

Is it a leap year?

This challenge is quite simple. You will take an input which will be a year from 1801 to 2400, and output if it is a leap year or not. Your input will have no newlines or trailing spaces: ...
48
votes
66answers
5k views

Depalindromize this string!

Given a palindrome generated according to this challenge, depalindromize it. Test cases ...
29
votes
53answers
8k views

The Smart Person's Mirage

Once upon a time, I was reading this question/answer on Quora Are there really programmers with computer science degrees who cannot pass the FizzBuzz test This code is given as the obvious answer <...
82
votes
25answers
7k views

Bake a slice of Pi

Write a program or function that prints or outputs this exact text (consisting of 142 characters): ...
29
votes
65answers
3k views

A square of text

The Challenge Given a string, output the text in the shape of a square. You can assume that the text will always fit in a square, and that it will never be an empty string. You can also assume it ...
30
votes
69answers
8k views

Check whether an integer is a power of 2 without using +,- operations [closed]

Write a program that checks if the integer is a power of 2. Sample input: 8 Sample output: Yes Sample input: ...
51
votes
32answers
8k 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 ...
46
votes
38answers
5k views

Fake Marquee Text

In this challenge fake marquee text is text that is shown part by part, in a scrolling-like fashion. Some examples: ...
24
votes
63answers
9k views

Count the number of ones in an unsigned 16-bit integer

Write some statement(s) which will count the number of ones in an unsigned sixteen-bit integer. For example, if the input is 1337, then the result is ...
86
votes
15answers
8k views

Create a programming language that only appears to be unusable

Robbers' challenge thread is here. Cops' challenge: Design a programming language that appears to be unusable for programming, but admits computation (or at least completion of the task) through some ...
53
votes
21answers
4k views

Print This Question ↓

The basic idea of a kolmogorov-complexity challenge is to print a set output in the shortest code (though that meaning has changed now). We have had many of them, from Borromean Rings to The ...
46
votes
17answers
11k views

Tips for golfing in Jelly

Jelly is a tacit, golf-oriented programming language by our very own Dennis. It’s popping up in answers here more and more often, beating other golf-y languages like Pyth and CJam, both by using its ...
41
votes
22answers
4k views

Remove every N-th N

The task In this challenge, your input is a non-empty list of positive integers, given in the native format of your language. Your output is that same list, in the same format, with some elements ...
44
votes
21answers
2k views

Tips for golfing in The Shakespeare Programming Language

What general tips do you have for golfing in The Shakespeare Programming Language? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to SPL ...
29
votes
29answers
3k views

Let's do the Wave!

Input: A string (the wave-snippet) with a length >= 2. A positive integer n >= 1. Output: We output a single-line wave. ...
33
votes
22answers
7k views

XOR multiplication

You goal is to implement the operation of XOR (carryless) multiplication, defined below, in as few bytes as possible. If we think of bitwise XOR (^) as binary ...
22
votes
48answers
2k views

Draw an alphabet party hat

Your task is to print this exact text: ...
5
votes
78answers
3k views

Summation from a to b

The program has an input of a and b, and outputs the sum of numbers from a to b, inclusive. Score is in bytes. As always, standard loopholes are disallowed. If your input is in the format [a,b], +3 ...
27
votes
18answers
6k views

Shortest Sorted Hello World

Write a program that takes no input and prints Hello, World! to stdout or your language's closest alternative. The catch is that each line in your program must only ...
24
votes
24answers
4k views

Shortest Minmod Function

The minmod function is a variant of the familiar min, which appears in slope-limiting high-resolution schemes for partial differential equations. Given a number of slopes, it picks out the flattest ...
30
votes
24answers
3k views

Palindromizing the strings

Introduction For the ones who don't know, a palindrome is when a string is equal to the string backwards (with exception to interpunction, spaces, etc.). An example of a palindrome is: ...
21
votes
32answers
3k views

Print out the first N characters of your code

You should write a program or function that receives a positive integer N as input and prints out the first N characters of your ...
26
votes
25answers
2k views

Home on the Range of Lists

This challenge is simply to return a list of lists of integers, similar to the Python range function, except that each successive number must be that deep in lists. Rules: Create a program or a non-...
40
votes
8answers
6k views

40 Numbers in 9 Bytes

There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid: This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for ...
34
votes
12answers
6k views

Code Golf of Death [closed]

Write some code that causes a BSOD or kernel panic! Rules: On Windows, you must cause a BugCheck (Blue Screen of Death), on Linux (or other *nix systems) you must cause a kernel panic. Must not ...
24
votes
23answers
3k views

How many times will a bell tower ring?

Introduction A bell tower will ring its bells every hour, n times, with n being the the current hour on a 12 hour clock. For ...

15 30 50 per page