Questions tagged [source-layout]
For challenges that involve the physical layout or physical manipulation of source-code.
189
questions
22
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 ...
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:
...
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 ...
22
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 ...
9
votes
10
answers
628
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-...
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-...
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 ...
14
votes
10
answers
923
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 ...
12
votes
10
answers
881
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 ...
25
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 ...
10
votes
5
answers
464
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
...
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 ...
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.
...
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, ...
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 ...
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 ...
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 ...
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 ...
12
votes
4
answers
527
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 ...
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 ...
6
votes
1
answer
341
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 (...
4
votes
6
answers
557
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 ...
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 ...
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 ...
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\$. ...
-14
votes
15
answers
323
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 ...
-12
votes
18
answers
424
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 ...
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 ...
4
votes
0
answers
204
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 ...
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 ...
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\$,...
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 ...
13
votes
3
answers
622
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. ...
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 ...
5
votes
3
answers
518
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 ...
55
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 ...
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 ...
3
votes
5
answers
612
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 ...
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 ...
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'...
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.
...
32
votes
22
answers
4k
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 ...
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 ...
11
votes
7
answers
489
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 ...
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 ...
28
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 ...
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 ...
54
votes
70
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 ...
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 ...
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 (...