All Questions

Filter by
Sorted by
Tagged with
89 votes
72 answers

Print your code backwards - reverse quine

Write a program that prints its own source code out backwards, in other words an eniuq. Scoring: +50 if you use pull data from the Internet. +25 if you read your own source code. +1 point per ...
ike's user avatar
  • 1,877
88 votes
28 answers

Bake a slice of Pi

Write a program or function that prints or outputs this exact text (consisting of 142 characters): ...
Copper's user avatar
  • 3,900
85 votes
222 answers

Sum of all integers from 1 to n

I'm honestly surprised that this hasn't been done already. If you can find an existing thread, by all means mark this as a duplicate or let me know. Input Your input is in the form of any positive ...
GarethPW's user avatar
  • 1,299
49 votes
24 answers

Tips for golfing in Pyth

Pyth is a Python-inspired procedural programming language, created by PPCG user isaacg. What general tips do you have for golfing in Pyth? I'm looking for ideas that can be applied to code golf ...
isaacg's user avatar
  • 42k
41 votes
9 answers

"Convenient palindrome" checker

If you've ever tried to write palindromic code before, you'd know how much brackets tend to get in your way. ()() is not a palindrome, even though it kinda looks ...
algorithmshark's user avatar
39 votes
15 answers

Tips for golfing in J

GolfScript gets its own way far too often and I feel that a repository of handy hints for golfing in J might help in the fight against the evil empire. What tips do you have for making this already ...
Gareth's user avatar
  • 11.3k
36 votes
17 answers

Find the nth decimal of pi

There are already 30 challenges dedicated to pi but not a single one asks you to find the nth decimal, so... Challenge For any integer in the range of ...
Bassdrop Cumberwubwubwub's user avatar
34 votes
18 answers

Wind me a number snake!

Given an input integer n, draw a number snake, that is, a grid measuring n x n consisting of the numbers ...
Julius's user avatar
  • 430
30 votes
31 answers

Josephus problem (counting out)

The challenge Write a function that takes two positive integers \$n\$ and \$k\$ as arguments and returns the number of the last person remaining out of \$n\$ after counting out each \$k\$-th person. ...
Howard's user avatar
  • 23.5k
28 votes
68 answers

Is string X a subsequence of string Y?

Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and ...
r.e.s.'s user avatar
  • 3,112
25 votes
9 answers

Tips for Golfing in Brain-Flak

Brain-flak is a stack-based turing-tarpit language, written collaboratively between me, DJMcMayhem, and 1000000000. Some users are very experienced in the mysterious ways of Brain-Flak. So I thought ...
Wheat Wizard's user avatar
  • 96.5k
16 votes
9 answers

Base Conversion With Strings

Introduction We've have a few base conversion challenges here in the past, but not many designed to tackle arbitrary length numbers (that is to say, numbers that are long enough that they overflow the ...
Mwr247's user avatar
  • 3,574
15 votes
2 answers

Golf the prime numbers in Shue

I'd like to introduce a new? programming language I call Shue (Simplified Thue). It has very simple syntax. Here is a program that checks if an input is divisible by three: ...
AnttiP's user avatar
  • 7,828
42 votes
17 answers

Tips for restricted source in Python

Just like code-golf, restricted-source pushes one to exploit quirks and hidden features of the Python language. We already have a place to collect all these tips for code-golf, those for restricted-...
Wheat Wizard's user avatar
  • 96.5k
129 votes
64 answers

Program that creates larger versions of itself (quine-variant)

You are to write a program that will output source code that is Larger than the original program (character wise) Will print another program larger than itself when run (i.e. the new program is also ...
PyRulez's user avatar
  • 7,197
102 votes
9 answers

Write an interpreter for 99

99 (pronounced "ninety-nine") is a brand new Esoteric programming language (not to be confused with 99, note the italics). Your task in this challenge is to write an interpreter for 99 that ...
Calvin's Hobbies's user avatar
74 votes
52 answers

Check if words are isomorphs

Two words are isomorphs if they have the same pattern of letter repetitions. For example, both ESTATE and DUELED have pattern <...
xnor's user avatar
  • 144k
74 votes
156 answers

The alphabet in programming languages

Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter. Input: none Output: ...
Joey Adams's user avatar
  • 10.6k
63 votes
44 answers

Find the Smoothest Number

Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest. A smooth number is one whose largest prime factor is ...
isaacg's user avatar
  • 42k
58 votes
70 answers

Am I a Fibonacci Number?

Your Task: Write a program or function to check if a number that is inputted is a Fibonacci number. A Fibonacci number is a number contained in the Fibonacci sequence. The Fibonacci Sequence is ...
Gryphon's user avatar
  • 7,199
54 votes
70 answers

I reverse the source code, you negate the output!

Your task, if you wish to accept it, is to write a program that outputs a non-zero number(can be integer or float). The tricky part is that if I reverse your source code, the output must be the ...
TwilightSparkle's user avatar
52 votes
81 answers

It's Hip to be Square

Challenge So, um, it seems that, while we have plenty of challenges that work with square numbers or numbers of other shapes, we don't have one that simply asks: Given an integer ...
Shaggy's user avatar
  • 41.6k
47 votes
35 answers

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 ...
xnor's user avatar
  • 144k
44 votes
18 answers

Shortest terminating program whose output size exceeds Graham's number

Write the shortest possible program (length measured in bytes) satisfying the following requirements: no input output is to stdout execution eventually terminates total number of output bytes exceeds ...
r.e.s.'s user avatar
  • 3,112
39 votes
54 answers


Related but very different. A boustrophedon is a text where every other line of writing is flipped or reversed, with reversed letters. In this challenge, we will just reverse every other line, but ...
Adám's user avatar
  • 29.9k
39 votes
53 answers

Determine the depth of an array

A simple challenge for your Monday evening (well, or Tuesday morning in the other half of the world...) You're given as input a nested, potentially ragged array of positive integers: ...
Martin Ender's user avatar
33 votes
7 answers

Match strings whose length is a fourth power

Within the scope of this question, let us consider only strings which consist of the character x repeated arbitrary number of times. For example: ...
n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳'s user avatar
29 votes
12 answers

Word Search Puzzle

Given a rectangular text as a word search puzzle and a search string, determine if the text contains the search string. The search string may appear: horizontally, vertically or diagonally forwards ...
Martin Ender's user avatar
27 votes
17 answers

Compute the multinomial coefficient

Time for another easy challenge in which all can participate! The multinomial theorem states: $$(x_1 + x_2 + \cdots + x_m)^n = \sum_{k_1 + k_2 + \cdots + k_m = n} \binom n {k_1, k_2, \dots, k_m} \...
quintopia's user avatar
  • 4,087
23 votes
30 answers

Code-Golf: Permutations

Write a function that takes as input a set of integers (can be a list, array or any other container with distinct numbers), and outputs the list of all its permutations. Python (95 chars): ...
zxul767's user avatar
  • 341
21 votes
51 answers

Run Length Decoding

Write the shortest code in the language of your choice to perform run length decoding of the given string. The string will be supplied as input on stdin in the form ...
Coding man's user avatar
  • 1,325
19 votes
5 answers

Most efficient cubifier

Cubically is too tedious to manually write any code in. Your challenge is to translate ASCII text into Cubically source code. Cubically This is just a quick run-down of Cubically; the repository has ...
MD XF's user avatar
  • 13.8k
14 votes
9 answers

Build a polyglot for Hello World

Produce a text file that prints "Hello World!" in as many programming languages as possible when compiled/interpreted, while also being as short as possible. The score for your submission is ...
Joe Z.'s user avatar
  • 34.7k
12 votes
19 answers

Find a Rocco number

I was asked this question in an interview but I was unable to figure out any solution. I don't know whether the question was right or not. I tried a lot but couldn't reach any solution. Honestly ...
vijayscode's user avatar
11 votes
7 answers

Determine the position of a non-negative number in the infinite spiral

Definition The infinite spiral used in this question has 0 on the position (0,0), and continues like this: ...
Leaky Nun's user avatar
  • 49.6k
1226 votes
6 answers

Build a working game of Tetris in Conway's Game of Life

Here is a theoretical question - one that doesn't afford an easy answer in any case, not even the trivial one. In Conway's Game of Life, there exist constructs such as the metapixel which allow the ...
Joe Z.'s user avatar
  • 34.7k
391 votes
156 answers

Write a program that makes 2 + 2 = 5 [closed]

Write a program that seemingly adds the numbers 2 and 2 and outputs 5. This is an underhanded contest. Your program cannot output any errors. Watch out for memory holes! Input is optional. ...
qwr's user avatar
  • 11.5k
247 votes
56 answers

Survival Game - Create Your Wolf

The Board The Board is a two dimensional array of cells. Cells are populated by Animals. Every day, all Animals on the Board simultaneously make one move. If two or more Animals move to the same cell, ...
Rainbolt's user avatar
  • 6,376
128 votes
201 answers

Sing Happy Birthday to your favourite programming language

Your favourite programming language has just had a birthday. Be nice and sing it the Happy Birthday song. Of course you should accomplish this by writing a program in that language. The program takes ...
David Frank's user avatar
  • 2,039
103 votes
41 answers

The Versatile Integer Printer

Write a piece of code that is executable in at least three different languages. The code must output the integer 1 in language number one, ...
Stewie Griffin's user avatar
71 votes
38 answers

Enlarge ASCII art

In this challenge, you must take multiline ASCII art as input, such as: ...
Doorknob's user avatar
  • 71.4k
68 votes
61 answers

N-dimensional N^N array filled with N

In: Enough memory and a positive integer N Out: N-dimensional N^N array filled with N, where N^N means N terms of N-by-N-by-N-by... Examples: 1: [1] ...
Adám's user avatar
  • 29.9k
57 votes
82 answers

Play the "bzzt" game

Winner: Aditsu's CJam answer! A whopping 25 bytes! Nice! You may continue to submit your answer, however you can no longer win. Original post kept for posterity: The "Bzzt" game is a game ...
Jon's user avatar
  • 1,573
57 votes
77 answers

Test a number for narcissism

A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits. For example, take \$153\$ (3 digits): \$1^3 + 5^3 + 3^3 = 153\$ \$1634\$: \$1^...
Iszi's user avatar
  • 2,538
53 votes
22 answers

Sᴍᴀʟʟ Cᴀᴘꜱ Cᴏɴᴠᴇʀᴛᴇʀ

Portable Spec. Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ. Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x. Sᴍᴀʟʟ ...
Maltysen's user avatar
  • 25.7k
52 votes
95 answers

Alphabet triangle

You are to print this exact text: ...
Leaky Nun's user avatar
  • 49.6k
47 votes
41 answers

Draw A Sierpinski Triangle

The Sierpinsky Triangle is a fractal created by taking a triangle, decreasing the height and width by 1/2, creating 3 copies of the resulting triangle, and place them such each triangle touches the ...
Kibbee's user avatar
  • 959
44 votes
21 answers

One Ring to rule them all. One String to contain them all

Objectives: Output a String which contains every positive integer strictly below 1000. The obvious answer would be to concatenate every one of them, and that would create a String of 2890 characters (...
Fabinout's user avatar
  • 633
37 votes
43 answers

Numbers with Rotational Symmetry

Given an integer, output a truthy value if it is the same upside-down (rotated 180°) or a falsy value otherwise. 0, 1, and ...
mbomb007's user avatar
  • 23.3k
36 votes
61 answers

Sum of primes between given range

Write the shortest code for finding the sum of primes between \$a\$ and \$b\$ (inclusive). Input \$a\$ and \$b\$ can be taken from command line or stdin (space seperated) Assume \$1 \le a \le b \le ...
st0le's user avatar
  • 2,208

15 30 50 per page
1 2
4 5