Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
1 vote
2 answers
331 views

I am looking to create a brainfuck program that can print the text "Hello, World" when executed--but not just that (it's too easy), it should also print "dlroW ,olleH" when the ...
Jore's user avatar
  • 137
9 votes
10 answers
2k views

Exposition You send secret information to 100 of your friends, and the next day you discover that the information has been published! Who could have revealed it? To determine that, you number your ...
anatolyg's user avatar
  • 14.1k
19 votes
3 answers
1k views

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
  • 79.3k
23 votes
10 answers
2k views

Just because the reverse and palindrome were not too challenging individually :) Write a program (full program or function) that satisfies the following: given a string input, the program as-is ...
Bubbler's user avatar
  • 79.3k
30 votes
44 answers
5k views

Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then: ...
mousetail's user avatar
  • 14.4k
27 votes
15 answers
4k views

Task Write a polyglot in two languages that when run, outputs the name of the language it is run in. Additionally, this program must also output the other language's name if the source code is ...
emirps's user avatar
  • 1,857
23 votes
4 answers
2k views

To increase data safety at our company, we are planning to start using Gray code numbers (where successive values differ by only one bit) instead of classical binary ones. Please help us to make a ...
Jiří's user avatar
  • 1,925
9 votes
10 answers
826 views

Cops' 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
20 votes
15 answers
2k views

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
28 votes
28 answers
4k views

Cops' Challenge Robbers' challenge here. It has now been four days since the challenge was posted so all new answers should be marked as non-competing in the title. These answers can still be cracked ...
Lecdi's user avatar
  • 1,165
14 votes
10 answers
1k views

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
  • 103k
13 votes
10 answers
1k views

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
  • 46.2k
26 votes
8 answers
2k views

In this challenge, you'll create some programs which behave similarly to genes. When you run one, it will return one of its two "alleles" (a half of its source code), and concatenating any ...
rydwolf's user avatar
  • 19.3k
10 votes
5 answers
560 views

The string abaaba Is a palindrome, meaning it doesn't change when it's reversed. However we can split it in half to make two palindromes ...
Wheat Wizard's user avatar
  • 103k
20 votes
7 answers
3k views

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
  • 103k
26 votes
11 answers
5k views

Write a program that outputs the exact string: jan ale o, toki! ("Hello, world" but in toki pona to prevent builtins.) with an optional trailing newline. ...
Wheat Wizard's user avatar
  • 103k
32 votes
8 answers
4k views

Write an \$n\$-bytes program \$AB\$ such that: it outputs an integer \$x,\ 0\lt x\lt n\$; both its \$x\$-byte prefix \$A\$ and \$(n-x)\$-byte suffix \$B\$, when run as programs, output \$AB\$. \$A, ...
Domenico's user avatar
  • 2,463
27 votes
7 answers
2k views

When this question was posted, it was caird coinheringaahing's birthday! (source: 1, 2, 3, 4) (It was also World Emoji Day.) As a bit of some CGCC lore, caird's name came from a Jelly answer by Dennis ...
hyperneutrino's user avatar
  • 42.8k
10 votes
44 answers
3k views

Cops thread Robbers, your task is to crack a cops answer. Reveal the character that should be changed and what it should be changed to too. Please notify the cop if you cracked their challenge. The ...
math scat's user avatar
  • 9,528
20 votes
49 answers
4k views

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,528
40 votes
31 answers
5k views

Challenge Write \$2 \le n \le 10\$ distinct, valid non-halting full programs in your language of choice. If all of them are concatenated in order, the resulting full program should be a valid halting ...
Bubbler's user avatar
  • 79.3k
12 votes
4 answers
571 views

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
  • 32.4k
10 votes
20 answers
3k views

Idea from the doubler challenge, this may be more difficult. The program should output a positive integer or decimal point value higher than 0. If I duplicate the source code, the output should halve ...
math scat's user avatar
  • 9,528
6 votes
1 answer
453 views

In Conway's Game of Life, there is an infinite square grid of cells, each of which is alive or dead. The pattern changes each "generation". A dead cell with exactly 3 live neighbors (...
Beefster's user avatar
  • 10k
4 votes
6 answers
649 views

This is alternate of a rip-off of 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 ...
okie's user avatar
  • 1,807
19 votes
25 answers
3k views

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
18 votes
20 answers
3k views

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,350
23 votes
19 answers
3k views

You are to write a program which outputs a single positive integer \$n\$. The integer may have leading zeros and whitespace, and/or trailing whitespace. Then, choose a positive integer \$m > 1\$. ...
caird coinheringaahing's user avatar
-14 votes
15 answers
452 views

For today's challenge you have to take an input, and if your source code is reversed, then the input should be printed doubled. Let's say your source code is ABC ...
user avatar
-13 votes
18 answers
560 views

You have to write a program, if its source code is reversed, then it will error. For example, if your source is ABC, then reversing it and writing ...
user avatar
33 votes
30 answers
3k views

Your task is to write a program or function. Its output/return value must follow these rules: The program outputs 1 The program repeated ...
rydwolf's user avatar
  • 19.3k
5 votes
0 answers
251 views

Introduction This challenge appeared in the 2020 Estonian Open Informatics Olympiad and was created Sandra Schumann. I thought it was interesting because it involves symmetry and is quite hard even to ...
Andi Qu's user avatar
  • 151
30 votes
38 answers
5k views

It's one of these again :D Your task, if you wish to accept it, is to write a program/function (without any uppercase letters) that outputs/returns its string input/argument. The tricky part is that ...
rydwolf's user avatar
  • 19.3k
27 votes
17 answers
2k views

Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$,...
Beefster's user avatar
  • 10k
40 votes
31 answers
5k views

Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not ...
Beefster's user avatar
  • 10k
13 votes
3 answers
663 views

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
  • 103k
29 votes
4 answers
4k views

Write a program for a specific language that in different orientations performs different tasks. Your code should have at least two non-empty lines and at least two non-empty columns and should ...
Dom Hastings's user avatar
  • 24.6k
5 votes
3 answers
573 views

A magic square is an \$ n \times n \$ square grid, such that the sum of the integers on each row and column are equal. Note that the definition which will be used in this challenge is different than ...
dingledooper's user avatar
  • 23.4k
57 votes
26 answers
9k views

Write a program that outputs its input unchanged. However: If all uppercase characters are removed from the program, it lowercases all uppercase letters. If all lowercase characters are removed from ...
darrylyeo's user avatar
  • 7,937
26 votes
10 answers
4k views

Write two programs, each taking a string s and a number n ≥ 0, such that: The first program prints ...
darrylyeo's user avatar
  • 7,937
5 votes
5 answers
692 views

Write a program that outputs the number 0. That's a bit trivial, isn't it? Let's sort all distinct permutations of your code in lexicographical order. When any of these codes are run, it should ...
user avatar
10 votes
4 answers
554 views

Write a program that outputs the number 0. That's a bit trivial, isn't it? Let the length of your program be \$S\$. Write a program that outputs the number 0. When your program is cyclically shifted ...
user avatar
35 votes
4 answers
3k views

In math a magic square is an N×N grid of numbers from 1 to N2 such that every row, column, and diagonal sums to the same total. For example here's a 3×3 magic square: In this challenge we'...
Calvin's Hobbies's user avatar
32 votes
57 answers
7k views

It's a normal truth machine but instead of taking input, it uses the first character of the program. Thus, internal. The 0 and 1 are plain characters, i.e. ASCII code 0x30 and 0x31 respectively. ...
PkmnQ's user avatar
  • 2,723
34 votes
22 answers
5k views

The task here is pretty simple. You should write a program that takes a string as input and outputs it (that is a cat program). Additionally when the \$n\$th byte of your program is removed (without ...
Wheat Wizard's user avatar
  • 103k
28 votes
24 answers
7k views

Sandbox A spin-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/argument. The ...
lyxal's user avatar
  • 35.6k
11 votes
7 answers
553 views

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 ...
Wheat Wizard's user avatar
  • 103k
38 votes
25 answers
7k views

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 ...
Adám's user avatar
  • 31.8k
29 votes
44 answers
7k views

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 ...
Night2's user avatar
  • 5,997
44 votes
69 answers
9k views

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 ...
Adám's user avatar
  • 31.8k