Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
18 votes
3 answers
927 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
  • 76.8k
23 votes
10 answers
2k views

I (rev)?(pal)? the source code, you (rev)?(pal)? the input!

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
  • 76.8k
30 votes
44 answers
4k views

Repeat your program to print Fibonacci numbers

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
  • 12.6k
26 votes
14 answers
3k views

Reverse the polyglot, change the language

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,797
23 votes
4 answers
1k views

Gray coded Gray code convertor

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,885
9 votes
10 answers
637 views

Two In One: Guess That Language - Robbers

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

What's the Missing Code? (Cops)

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,155
14 votes
10 answers
927 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.8k
13 votes
10 answers
893 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
  • 38.4k
26 votes
8 answers
2k views

Write some Genetic Quines

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 Programs's user avatar
10 votes
5 answers
468 views

The Most Palindromy Code to Calculate Palindromy Numbers

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
  • 98.8k
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.8k
25 votes
9 answers
5k views

Make a Hello World using as many bytes as possible

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
  • 98.8k
32 votes
7 answers
4k views

I'm a lizard, cut here!

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,303
28 votes
7 answers
2k views

Happy Birthday... caird coinheringaahing? ChartZ Belatedly?

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 ...
hyper-neutrino's user avatar
  • 42.4k
10 votes
44 answers
3k views

Which character to change (Robbers)

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,368
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,368
39 votes
31 answers
4k views

Concatenated halting problem: no + no + ... = yes

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

Double it? Then halve it! But multiply it? Then divide it!

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,368
6 votes
1 answer
354 views

Two Diehards Make a Glider

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
  • 9,951
4 votes
6 answers
573 views

I Rot-13 the source code, you Rot-19 the output!

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

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
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
23 votes
19 answers
2k views

What's the odd one out?

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 coinheringaahin g's user avatar
-13 votes
15 answers
336 views

Reverse source code and double the input

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
-12 votes
18 answers
443 views

Reverse and error!

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
34 votes
30 answers
3k views

Count how many times your program repeats

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 Programs's user avatar
4 votes
0 answers
218 views

5 tasks in (modified) BrainF**k from the Estonian OI [closed]

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
  • 141
30 votes
38 answers
4k views

I uppercase the source code, you reverse the input!

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 Programs's user avatar
27 votes
17 answers
2k views

Quineoid Triple - A(B) = C

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
  • 9,951
39 votes
29 answers
5k views

Cat, Quine, Hello World

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
  • 9,951
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.8k
30 votes
4 answers
3k views

Orientation Oriented Programming

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
  • 23.8k
5 votes
3 answers
522 views

Magic Square, Magic Code

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
  • 22.7k
56 votes
26 answers
9k views

DON'T... do NOT lowercase UPPERCASE this!

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,897
26 votes
10 answers
3k views

Your code has an uncanny mirror twin…

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

Determine the lexicographical permutation your code is in

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
8 votes
4 answers
515 views

Determine the cyclical shift your program is in

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

Make The Finest Magic Code Square

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
6k views

Internal Truth Machine

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,693
32 votes
22 answers
5k views

Pass on your radiation

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
  • 98.8k
28 votes
24 answers
7k views

I shift the source code, you shift the input!

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
  • 33.5k
11 votes
7 answers
490 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 ...
Wheat Wizard's user avatar
  • 98.8k
38 votes
25 answers
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 ...
Adám's user avatar
  • 30.3k
29 votes
44 answers
7k 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 ...
Night2's user avatar
  • 5,957
44 votes
68 answers
8k 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 ...
Adám's user avatar
  • 30.3k
57 votes
72 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 ...
TwilightSparkle's user avatar
33 votes
29 answers
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 ...
GammaFunction's user avatar