All Questions
4,641
questions
89
votes
72
answers
15k
views
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 ...
88
votes
28
answers
8k
views
Bake a slice of Pi
Write a program or function that prints or outputs this exact text (consisting of 142 characters):
...
85
votes
222
answers
17k
views
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 ...
49
votes
24
answers
8k
views
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 ...
41
votes
9
answers
6k
views
"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 ...
39
votes
15
answers
4k
views
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 ...
36
votes
17
answers
12k
views
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 ...
34
votes
18
answers
4k
views
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 ...
30
votes
31
answers
3k
views
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.
...
28
votes
68
answers
8k
views
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 ...
25
votes
9
answers
2k
views
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 ...
16
votes
9
answers
2k
views
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 ...
15
votes
2
answers
881
views
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:
...
42
votes
17
answers
6k
views
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-...
129
votes
64
answers
40k
views
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 ...
102
votes
9
answers
7k
views
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 ...
74
votes
52
answers
6k
views
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 <...
74
votes
156
answers
18k
views
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:
...
63
votes
44
answers
14k
views
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 ...
58
votes
70
answers
11k
views
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 ...
54
votes
70
answers
11k
views
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 ...
52
votes
81
answers
7k
views
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 ...
47
votes
35
answers
14k
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 ...
44
votes
18
answers
6k
views
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 ...
39
votes
54
answers
4k
views
Boustrophedonise
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 ...
39
votes
53
answers
11k
views
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:
...
33
votes
7
answers
5k
views
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:
...
29
votes
12
answers
3k
views
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 ...
27
votes
17
answers
3k
views
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} \...
23
votes
30
answers
3k
views
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):
...
21
votes
51
answers
4k
views
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
...
19
votes
5
answers
2k
views
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 ...
14
votes
9
answers
3k
views
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 ...
12
votes
19
answers
1k
views
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 ...
11
votes
7
answers
799
views
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:
...
1226
votes
6
answers
299k
views
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 ...
391
votes
156
answers
288k
views
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.
...
247
votes
56
answers
55k
views
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, ...
128
votes
201
answers
34k
views
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 ...
103
votes
41
answers
13k
views
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, ...
71
votes
38
answers
12k
views
Enlarge ASCII art
In this challenge, you must take multiline ASCII art as input, such as:
...
68
votes
61
answers
7k
views
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] ...
57
votes
82
answers
12k
views
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 ...
57
votes
77
answers
8k
views
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^...
53
votes
22
answers
6k
views
Sᴍᴀʟʟ Cᴀᴘꜱ Cᴏɴᴠᴇʀᴛᴇʀ
Portable Spec.
Iɴꜱᴘɪʀᴇᴅ ʙʏ @ConorO'Brien's ᴜꜱᴇʀɴᴀᴍᴇ.
Aʟꜱᴏ ᴛʜᴀɴᴋꜱ ᴛᴏ @Dᴏᴏʀᴋɴᴏʙ ꜰᴏʀ ꜱʜᴏᴡɪɴɢ ᴍᴇ ᴛʜᴇ ᴇxɪꜱᴛᴇɴᴄᴇ ᴏꜰ ǫ ᴀɴᴅ x.
Sᴍᴀʟʟ ...
52
votes
95
answers
9k
views
Alphabet triangle
You are to print this exact text:
...
47
votes
41
answers
19k
views
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 ...
44
votes
21
answers
5k
views
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 (...
37
votes
43
answers
8k
views
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 ...
36
votes
61
answers
5k
views
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 ...