The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
16
votes
23answers
5k views

I reverse the source code, you reverse the input!

Yet another blatant rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its string input/argument. The tricky ...
8
votes
4answers
290 views

A Change in Perspective

In this challenge you will write a piece of text which when viewed from two different angles will create two different programs. Your string as viewed from above must take a string containing only ...
35
votes
50answers
7k views

I reverse the source code, you negate the input!

Blatant rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I ...
19
votes
21answers
1k views

The reversible reverser

Your task is simple. The program reads in a line of text from the standard input, and it prints out the same text in a character-reversed form. It is not allowed to print anything else. For example: ...
-8
votes
29answers
568 views

Reversible program

Objective Write a program that outputs some printable ASCII characters. The trick is that if the program is reversed byte-by-byte, it must output the same thing in the reverse order, byte-by-byte, ...
31
votes
29answers
5k views

Double it your way

There have been a couple of challenges involving doubling source code: here and here. The task we have here is a bit harder, but should be doable in almost every language. In this challenge, you will ...
38
votes
55answers
9k 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 ...
31
votes
21answers
6k views

I transpose the source code, you transpose the input!

Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that ...
55
votes
24answers
6k 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, ...
127
votes
130answers
17k views

I double the source, you double the output!

Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). The tricky part is that if I duplicate your source code, the output must be double the ...
17
votes
15answers
3k views

I multiply the source, you (probably) multiply the output!

Task The task is to write a program that outputs a consistent but otherwise arbitrary positive integer \$x\$ (so strictly greater than 0). Here's the catch: when the source is repeated \$N\$ times (...
49
votes
50answers
4k views

Third time the charm

Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if ...
36
votes
24answers
5k views

Double-time is not double time

Based on this challenge. In the rhythm game osu!, the difficulty modifier "Double-time" actually only increases the speed by 50%. Your task, is to write a program that outputs a positive even ...
45
votes
19answers
5k views

Create a square of increasing size by replicating the initial code

Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the ...
18
votes
18answers
2k views

“Hello, World!” (Every other character, Part 2)

As a kind of part 2 to Hello, World! (Every other character), write a program such that all three of these programs print "Hello, World!": the entire program, the 1st, 3rd, 5th, etc. characters of ...
116
votes
42answers
16k views

Write a program that always outputs “2012” - even if it's modified!

This idea is not mine, though I don't know where it originated. I once met it in a programming contest very long ago (1998, if I remember correctly). The task is to write a program in your favorite ...
40
votes
19answers
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 ...
29
votes
28answers
2k views

Concatenative counting

Your challenge is to write N snippets of code such that, when you concatenate the first K ≥ 1 together, they produce the number K. The higher N, the better. Here's the catch: you may not use any ...
11
votes
5answers
386 views

Reverse your code, reverse the OEIS

The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of ...
31
votes
19answers
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 ...
29
votes
13answers
2k views

Make a Geiger Counter

A Geiger counter is a device that is used to detect radiation. We will be making a Geiger counter program. As we all know, when radiation hits a computer program it removes exactly 1 byte at random. ...
40
votes
12answers
2k views

A well linked challenge

An activity I sometimes do when I'm bored is to write a couple of characters in matching pairs. I then draw lines (over the tops never below) to connect these characters. For example I might write \$...
8
votes
32answers
2k views

Square and square [closed]

Squares looks symmetric, and so are the required codes. Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a ...
101
votes
32answers
11k 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 ...
31
votes
9answers
7k 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!. ...
14
votes
2answers
608 views

Error-detecting Self-repairing Program

Your task is to create a program where if any one character is deleted, it will detect which character was deleted and then re-insert the deleted character in its own source file. For instance, if ...
45
votes
23answers
4k views

A Chiral Puzzle

A shape is chiral if no amount of rotation can make it look like it's mirror image. In this puzzle we will be writing chiral computer programs. For this puzzle we will think of a program as a ...
10
votes
11answers
904 views

N times program for the N-th number

Given an array of positive integers A as the input, generate a program that, when repeated for k times, output the ...
33
votes
3answers
2k 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, ...
74
votes
54answers
6k views

From Programming Puzzles to Code Golf

Your task is to write a program that outputs the exact string Programming Puzzles (trailing newline optional), but when all spaces, tabs, and newlines are removed ...
4
votes
7answers
386 views

Just Twice Is Nice

Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell: ...
22
votes
5answers
3k views

Onion Programming

Using only printable ASCII (hex codes 20 to 7E), write a square N×N core program without comments that is surrounded by 4 more layers, creating a (N+8)×(N+8) square program (N > 0). For N = 3 the ...
12
votes
21answers
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 ...
100
votes
25answers
15k views

Print a Negative of your Code

Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6): ...
33
votes
11answers
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 ...
25
votes
20answers
3k views

Shape Identifying Program

Your task is to build a program that identifies the shape of the input. The shapes to be identified can be any of the following: Square To be identified as a square, the source must have lines of ...
12
votes
21answers
2k views

Longest Increasing Substring

Given a list of positive integers, write code that finds the length of longest contiguous sub-list that is increasing (not strictly). That is the longest sublist such that each element is greater ...
13
votes
8answers
1k views

Backhanded Compliments

This challenge is created in celebration of my first esoteric language, Backhand! Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only ...
11
votes
9answers
1k views

Everyone Ought to Have a Friend

An isolated character is a character (other than a newline) that doesn't have an adjacent character of the same type. Adjacent characters can be to the left, the right above or below, but not ...
23
votes
28answers
3k views

Take a stand against long lines

Recently, someone proposed more stringent limits for Python's default line length: Clearly, no program should ever use more than 80 characters per line, for a whole host of reasons. First and ...
31
votes
7answers
5k views

What did we forget?

Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified ...
37
votes
28answers
4k views

Is the matrix centrosymmetric… and so is the code?

Defintion A centrosymmetric matrix is a square matrix that is symmetric about its center. More rigorously, a matrix \$A\$ of size \$n \times n\$ is centrosymmetric if, for any \$i,\: j \in ([1, n] \...
41
votes
9answers
5k views

Shifting-Oriented Programming

A string can be shifted by a number n by getting the byte value c of each character in the string, calculating ...
16
votes
17answers
2k 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 ...
30
votes
8answers
3k 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 ...
13
votes
7answers
414 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: ...
24
votes
23answers
1k views

Cardinal Code Challenge

Task You're in charge of making a compass, of sorts. Imagine your source code as the compass "needle" where running at different orientations produces distinct output. Supported source code ...
10
votes
6answers
424 views

Self-Validating Triangular Checkerboard Program

A checkerboard program is a program where each individual character's ordinal value alternates from even to odd, excluding the line terminator (which can be any standard line-endings). A triangular ...
25
votes
25answers
2k views

Detect Perfect Pairings

Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap ...
19
votes
21answers
2k views

The repetitive byte counter

Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M. You should, in theory, support an ...