For challenges that involve the physical layout or physical manipulation of source-code.

learn more… | top users | synonyms

79
votes
25answers
7k views

What are the five most powerful characters in your language?

Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 ...
32
votes
20answers
2k views

Figure and Ground

Source: Wikipedia For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure and the other prints ground. ...
33
votes
16answers
3k views

Program template for printing *any* string

Write a program with the following properties: When run as-is, the program produces no output (i.e. 0 bytes of output). There is a location within the program (of your choice: it could be at the ...
8
votes
10answers
305 views

Make your program sequential! [closed]

Your task, if you choose to accept it, is simple. Objective You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a ...
13
votes
2answers
999 views

Primes with a twist

Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated n times in place. Let's say your program is: Derp ...
24
votes
2answers
421 views

Hyper about quines

Inspired by Hyperprogramming: N+N, N×N, N^N all in one. Thanks to @MartinEnder and @trichoplax for their help in the sandbox. Definitions Hyperquines Define a hyperquine of order n as a quine-...
126
votes
4answers
11k views

Hyperprogramming: N+N, N×N, N^N all in one

Write a program that takes in a number N from 1 to 9 inclusive. In its native form your program should output N+N. E.g. output 2 if N is 1, 4 if N is 2, 6 if N is 3, and so on. When every character ...
1
vote
1answer
222 views

“HHeelllloo,, EEaarrtthh!!” [duplicate]

Much like this challenge, write a program or function that takes no input and prints or returns the string Hello, Earth! with an optional trailing newline. The catch is that your program must be an ...
16
votes
2answers
351 views

Chuck Norris vs Travelling Salesman

Introduction Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle which is to say the shortest path ...
17
votes
15answers
2k views

Write a program that outputs the number of times it has been run [duplicate]

In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1. ...
11
votes
2answers
325 views

Right and tfeL truncatable primes

A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't ...
15
votes
3answers
2k views

Write a program that always prints N when it is shifted N times up the ASCII alphabet

Write a program using only printable ASCII characters that takes no input. For reference, here are the 95 printable ASCII characters in order: !"#$%&'()*+,-./0123456789:;<=>?@...
17
votes
7answers
893 views

Normal and visual string reversion

Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual ...
44
votes
2answers
4k views

Coding Around The Clock

Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be: MyProgram When your program is arranged into the ...
13
votes
11answers
1k views

Double-duty quine: quine!dlroW ,olleH

Write a program that will output its own source code when run, and nothing else. Seems easy, right? The catch is that when the source code is reversed, your program must output "Hello, World!" ...
12
votes
19answers
1k views

Sequential Multiplication

Your objective is to write a program that takes an input, and, when chained together N times, performs "sequential multiplication". What is sequential multiplication, you may ask? It's a sequence with ...
27
votes
17answers
2k views

Inverse function

Wouldn't it be neat if programming functions could be inverted, just like the mathematical function they implement? Write a function (or program) that takes one input x in any form, that outputs ln(...
7
votes
3answers
139 views

The confused twister

The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source ...
29
votes
7answers
6k views

Build a twisted “Hello world!”

Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!. How strings are twisted The twisting algorithm is very simple. Each ...
20
votes
2answers
431 views

Compile Regexes (By Substitution)

Your task is to compile regexes... by specifying a substitution for each character in a regex. Regexes The regexes support these REGEX = (LITERAL REGEX / GROUP REGEX / STAR REGEX / ...
14
votes
1answer
754 views

90° Self-Rotating Program

Introduction Write a complete program that rotates a rectangular block of ASCII characters 90 degrees clockwise. When the program itself is rotated 90 degrees clockwise, it rotates a block of ASCII ...
16
votes
5answers
1k views

Print a Symbolic Negative of your Code

(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.) Let's consider the symbols to be the following printable ...
27
votes
7answers
2k views

Source Code Metamorphosis

mbomb007 asked us to make a self mutilating program. Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating. I like to think that, at the heart of ...
16
votes
17answers
1k views

Self-Mutilating Program

Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as. Please include the beginning source ...
27
votes
7answers
2k views

Beatles Songs and Hexagons

Write two triangle (i.e. pyramid) shaped programs. The first one should be an upwards pointing text triangle with a minimum base width of three characters. So it would have a structure like X XXX ...
38
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 ...
64
votes
23answers
7k views

More is less and less is more

Anybody can make the output of a program bigger by adding characters, so let's do the exact opposite. Write a full program, an inner function or a snippet for a REPL environment in a language of your ...
2
votes
0answers
207 views

Recursive zipper reincarnation

Recursive zipper reincarnation Objective: Code two separate programs A and B that when concatenating their respective outputs OA + OB creates a third program: C. When program C runs it should ...
22
votes
6answers
1k views

XOR encrypt your programs with the source of other programs

Write two programs such that when the bytes of their source code are XOR-d together it produces a third, valid program, all in the same language. The length of each of the three programs in bytes must ...
31
votes
6answers
3k views

Write A Program That Outputs Its Mirror Level

There are 95 printable ASCII characters: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ In the Consolas font (the Stack Exchange code block ...
27
votes
7answers
2k views

Multiplication by Self-Modification

...at least for some definition of "self-modification". The Task In this challenge, your task is to write three strings A, B and C that satisfy the following properties. The string B has length at ...
15
votes
6answers
410 views

Princely Prefix by a Program in Pattern

You should write a program or function which outputs or returns as much of Chapter I of The Little Prince as it can. Your program or function has to be an M-by-N block of code containing only ...
20
votes
1answer
723 views

Programming Tetris Blocks (Literally)

In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments: The have the names I, J, L, O, S, T, ...
9
votes
4answers
272 views

Row, Column, Diagonal, Block

Write a square block of code that is N characters wide and N characters tall, for some positive integer N. For instance, your N may be 5 and the block look like this: ThisI sMy5B y5Cod eBloc kOkay ...
21
votes
4answers
2k views

Pure Sourcery - Shaping programs that output the digits 0 through 9

Here's a pixelated 5 by 7 font for the digits 0 through 9: .███. █...█ █...█ █...█ █...█ █...█ .███. ..█.. ███.. ..█.. ..█.. ..█.. ..█.. █████ .███. █...█ ....█ ...█. ..█.. .█... █████ .███. █...█ ...
44
votes
16answers
5k views

Sierpinskified Code

Write a rectangular block of text that when arranged into a Sierpinski carpet, using same-sized blocks of spaces for the empty portions, creates a program that outputs the iteration number of the ...
21
votes
12answers
2k views

Reading Code in 8 Ways to Output 8 Numbers

The English language and most programming languages are written and read from left-to-right, top-to-bottom, but that needn't be the case. In fact for the block of text ABC DEF I can think of eight ...
32
votes
8answers
4k views

One hundred passwords

I have one hundred vaults, each one within another. Each vault has a password, consisting of a single number. 95 43 81 89 56 89 57 67 7 45 34 34 78 88 14 40 81 23 26 78 46 8 ...
29
votes
24answers
2k views

Join N copies of a snippet to produce N^2 characters

Write the shortest snippet of code possible such that, when N copies of it are strung together in a larger program, the number of characters output is N2. N is a positive integer. For example if the ...
4
votes
0answers
82 views

Resistent counter [duplicate]

You just have to ouput exactly all the numbers from 1 to 10 separated by spaces. Your programme should work all the times even if a random character is deleted before compiling/interpreting. This is ...
16
votes
36answers
3k views

The Jigsaw Code Puzzle

This is an answer-dependent challenge! The order of answers matters, and your exact task depends on the last answer that was posted. You might want to sort the answers by oldest. Let's piece together ...
7
votes
4answers
463 views

Write a binary counter in quine

Write two code fragments, which we will call s_zero and s_one. Program (l, n) consists of l copies of s_zero and s_one corresponding with the digits of n in binary, padded with s_zero on the left. ...
10
votes
4answers
681 views

Put the line in the code you nut and shake it all up

Using one programming language write 5 single-line programs, each of which outputs a different line of the first verse to Harry Nilsson's 1972 song "Coconut" when run individually: Brother bought a ...
1
vote
4answers
411 views

All those duplicate questions deserve duplicate code to show them off

All those questions that are duplicates... Ignored and marginalized by society. It is just not... right. We have to do something. There surely must be love for them too. They feel appreciated if a ...
6
votes
3answers
441 views

Retrograde morse (d)e(n)coder

This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar ...
10
votes
1answer
517 views

Code a Code Slidey Puzzle!

The most recognizable sliding puzzle is the fifteen puzzle. It has a 4 by 4 grid, 15 tiles, and one empty grid space. The tiles can only move into the empty space and must always be in line with the ...
12
votes
1answer
223 views

Golf some quine stripes in different languages

You will choose m languages and write n programs in each language, each with length n*m. The kth program should output the kth character of each program, ordered by the program number. For example, ...
18
votes
9answers
1k views

Caesar-Cypher-Mania

The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII ...
51
votes
20answers
5k views

Significant Whitespace

We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20). For this challenge, you're to write two programs or functions in the same programming language, ...
22
votes
6answers
2k views

Mutual Negative Quines

This was inspired by Print a Negative of your Code and Golf a mutual quine. Consider a rectangle of characters, that meet the following restrictions: Consists solely of printable ASCII characters ...