Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
21 votes
3 answers
2k views

Anagramming Stack Exchange question titles into programs

Stack Exchange currently has 134 question and answer sites. This includes all beta sites (such as PPCG) but not Area 51 proposals nor any meta sites, except for the "mother meta". To answer ...
Calvin's Hobbies's user avatar
21 votes
2 answers
513 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 ...
Xwtek's user avatar
  • 2,039
21 votes
2 answers
622 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 ...
NonlinearFruit's user avatar
20 votes
49 answers
3k views

Which character to change (Cops)

Robbers Thread Cops, your task is to chose a program that prints a string (you can choose). Although, if you change 1 character in your code, it should print another string. But there's a twist: You ...
math scat's user avatar
  • 9,228
20 votes
20 answers
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 ...
pommicket's user avatar
  • 3,157
20 votes
7 answers
3k views

Hello, Toroidal Earth!

Your task is to create a program that outputs the string: Hello, Toroidal Earth! with an optional trailing newline. Additionally if I remove the first line1 of ...
Wheat Wizard's user avatar
  • 98.5k
20 votes
15 answers
4k 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 (...
Mr. Xcoder's user avatar
  • 42.4k
20 votes
4 answers
2k views

The Fatal Error Challenge

Objective Write a routine that accepts a string of printable ASCII characters, s, and returns a string containing the same characters as s, reordered so that no two-character substring appears more ...
COTO's user avatar
  • 3,691
19 votes
18 answers
3k views

Write a program that is valid after circular character shift

Potentially very difficult, but I've seen some amazing things come out of this site. The goal is to write a program, in any language, that does whatever you want. The catch is that the program must ...
Griffin's user avatar
  • 4,765
19 votes
25 answers
3k views

I palindrome the source code, you palindrome the input!

This is a rip-off of a rip-off of a rip-off of a rip-off of a rip-off. Go upvote those! Your task, if you accept it, is to write a program/function that outputs/returns its input/args. The tricky ...
okie's user avatar
  • 1,807
19 votes
21 answers
2k 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: ...
vsz's user avatar
  • 8,137
19 votes
22 answers
3k 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 ...
Mr. Xcoder's user avatar
  • 42.4k
19 votes
21 answers
2k views

Find the Needle in the Haystack (Robbers)

This is part of a cops-and-robbers challenge. Go here for the cops' part. The Robbers' Challenge A cop's answer can be cracked by removing any subset of characters from the Haystack program, so that ...
Martin Ender's user avatar
19 votes
15 answers
2k views

Two In One: Guess That Language - Cops

Robber's challenge This cops-and-robbers challenge challenges the Cop to write a non-empty program that, when run, produces some non-empty output in language A, and, when reversed, produces some non-...
Number Basher's user avatar
19 votes
10 answers
1k views

Make an interweaving quine

Your task is to create a program that, when run, returns itself as output (this is known as a quine). However, this quine must, when it is copied n times, returns ...
clismique's user avatar
  • 6,980
19 votes
15 answers
2k views

Write a function that tells you which TWO of its lines has been removed

In my previous code challenge, I asked you to write a function that tells you which of its lines has been removed. The instructions were: Write a function that contains five lines. If you run ...
jawns317's user avatar
  • 1,152
19 votes
3 answers
1k views

Choose-Your-Own-Language Code

Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the ...
Martin Ender's user avatar
18 votes
20 answers
2k views

Hello, Permutations!

For this challenge, you will be required to write 3 programs: The first program should be a quine, i.e, it should print it's own source code. The second program should read the input and print all of ...
Manish Kundu's user avatar
  • 5,270
18 votes
36 answers
4k 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 ...
Martin Ender's user avatar
18 votes
4 answers
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 ...
Luke's user avatar
  • 5,391
18 votes
4 answers
934 views

Build a half cardinal cyclic quine

A half cardinal cyclic quine is a cyclic quine with two states, one perpendicular to the other. Rules You can decide which rotation you want to implement, clockwise or counter-clockwise. Once ...
Dom Hastings's user avatar
  • 23.5k
17 votes
15 answers
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. ...
Calvin's Hobbies's user avatar
17 votes
7 answers
2k views

Russian Nesting Quine

A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller ...
Jo King's user avatar
  • 47.2k
17 votes
7 answers
964 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 ...
jimmy23013's user avatar
17 votes
3 answers
901 views

Magical BF: BF code that works in two ways

Challenge In this challenge, we will use a language that is very similar to Brainfuck but slightly different. This variant of BF does not have any input and output commands; instead, it simply takes ...
Bubbler's user avatar
  • 76k
16 votes
15 answers
2k views

Hidden Inversions (Robbers' Thread)

This is a cops-and-robbers puzzle, the cops' thread can be found here. Your task will be to find an anagram of the provided programs in the cops' thread that performs its left inverse. Once you ...
Wheat Wizard's user avatar
  • 98.5k
16 votes
13 answers
2k 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!" ...
ericw31415's user avatar
  • 2,302
16 votes
5 answers
1k views

Code close to the challenge: Inception

This is a sequel to this challenge: Code close to the challenge: Sum of integers The challenge in this one is a bit harder, and also makes for a cool title (Which is why I picked it): Calculate ...
user avatar
16 votes
6 answers
471 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 ...
randomra's user avatar
  • 20.9k
15 votes
2 answers
5k 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 ...
clismique's user avatar
  • 6,980
15 votes
3 answers
3k 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: ...
Calvin's Hobbies's user avatar
14 votes
17 answers
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 as ...
mbomb007's user avatar
  • 23.4k
14 votes
7 answers
997 views

Avoid duplicate entries using a sign change

This anecdote contains the following intriguing exchange: "Fine, Fred," Avi interrupted. "Then how would you change this to avoid duplicate entries?" "Oh, just change that one there to a ...
histocrat's user avatar
  • 22.2k
14 votes
10 answers
925 views

Find the biggest chunk

This challenge is not code golf. Please read the scoring before you attempt to submit an answer. You will be given a multi-line string as input. You should output the size of the largest contiguous ...
Wheat Wizard's user avatar
  • 98.5k
14 votes
8 answers
492 views

Deranged Rearrangements

Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n ...
Wheat Wizard's user avatar
  • 98.5k
14 votes
2 answers
777 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 ...
Beefster's user avatar
  • 9,931
13 votes
21 answers
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 ...
Seadrus's user avatar
  • 1,395
13 votes
23 answers
3k 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 ...
Wheat Wizard's user avatar
  • 98.5k
13 votes
8 answers
487 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: ...
Calvin's Hobbies's user avatar
13 votes
10 answers
892 views

From code to golf (Cops' thread)

This is a cops-and-robbers challenge, the robbers' thread is here You can change the word code into golf by changing a letter at ...
emanresu A's user avatar
  • 37.8k
13 votes
8 answers
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 ...
Jo King's user avatar
  • 47.2k
13 votes
5 answers
517 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 ...
Wheat Wizard's user avatar
  • 98.5k
13 votes
3 answers
623 views

Writing erasable code

My phone number (which I will not be sharing here) has a neat property where there is a two digit number, which when iteratively removed from my phone number will eventually remove all the digits. ...
Wheat Wizard's user avatar
  • 98.5k
13 votes
1 answer
328 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, in ...
jimmy23013's user avatar
13 votes
1 answer
845 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 ...
Calvin's Hobbies's user avatar
12 votes
6 answers
860 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 ...
Calvin's Hobbies's user avatar
12 votes
4 answers
531 views

Shrinking Triangles

Write an infinite list of triangle codes, defined as code where the i-th line has i bytes for all lines, such that the i-th code generates (i-1)th code and has 1 more line than the (i-1)th code. The ...
l4m2's user avatar
  • 23.9k
12 votes
2 answers
478 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 ...
Nathan Merrill's user avatar
11 votes
5 answers
672 views

Code Crosswords - Solutions

This is the companion question for Code Crosswords. Robber answers go here. See Where should we put robbers? for meta-info.
Calvin's Hobbies's user avatar
11 votes
9 answers
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 ...
Wheat Wizard's user avatar
  • 98.5k