Questions tagged [source-layout]
For challenges that involve the physical layout or physical manipulation of source-code.
188
questions
27
votes
28
answers
4k
views
+500
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 ...
66
votes
36
answers
7k
views
Write a Rectangular Program that Outputs the Number of Times it was Rotated
The title says it all. Your goal is to write a program that forms a w×h rectangle of characters that can be rotated and re-run to output the number of 90° Counter-Clockwise (CCW) rotations that have ...
25
votes
11
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 ...
144
votes
90
answers
23k
views
Hello, World! (Every other character)
Write a program that prints "Hello, World!".
But also, if you take only the first, third, fifth, etc. characters of your program, the resulting program should still print "Hello, World!".
If your ...
63
votes
38
answers
9k
views
Factorial in haiku!
Task
Create a program that calculates the factorial of a number using no built-in factorial functions. Easy? The catch is that you must write your entire program (including testing it) in haiku form.
...
10
votes
5
answers
1k
views
Program that prints mirror images of it's own self
Write a program that produces mirror images of itself. An example, would be the fantastic camel code that reads it's own code and produces two smaller 2x2 versions. Given the input:
...
29
votes
13
answers
2k
views
Write a function that tells you which of its lines has been removed
Write a function that contains five lines.
If you run the function as-is, it should return 0.
If you remove any one of the five lines and run the function, it should tell you which of the lines has ...
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 ...
149
votes
155
answers
21k
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 ...
27
votes
21
answers
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 ...
40
votes
25
answers
4k
views
Hide the Needle in the Haystack (Cops)
This is part of a cops-and-robbers challenge. Go here for the robbers' part.
The Cops' Challenge
You should write a program or function in a language of your choice, which outputs the string ...
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 ...
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 ...
43
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 ...
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.
...
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 ...
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!" ...
83
votes
17
answers
7k
views
Fault-Tolerant Hello World
At the end of your interview, the Evil Interviewer tells you, "We make all of our applicants take a short coding test, to see if they really know what they are talking about. Don't worry; it's ...
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 ...
39
votes
20
answers
3k
views
Prime Up your code
Input
no input for this challenge
The Challenge
Write a code that outputs:
The first 10 prime numbers whose sum of their digits equal the number of bytes of your code
Examples
Let's say your code is <...
27
votes
27
answers
2k
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 ...
30
votes
65
answers
3k
views
Palindrome Hello, World
Your task is to create a program that prints "Greetings, Planet!" exactly to the console. Seems simple enough, right? Well, here's the trick. The code must be a palindrome, meaning it reads from right ...
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 ...
-13
votes
18
answers
382
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 ...
53
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 ...
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-...
9
votes
10
answers
602
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-...
20
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 ...
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 ...
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 ...
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 ...
124
votes
21
answers
18k
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 ...
-9
votes
29
answers
633
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, ...
56
votes
25
answers
8k
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 ...
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 ...
22
votes
7
answers
2k
views
Run the Nth characters to get N
Write the shortest program possible such that when you combine the first character and every Nth character after it into a new program, the output is N. This must work for N = 1, 2, ..., 16.
Another ...
14
votes
10
answers
908
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 ...
24
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 ...
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 ...
13
votes
1
answer
324
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 ...
28
votes
12
answers
2k
views
Mandoline quine
Write a quine... from which every other character can be removed it still be a valid quine. You can specify whether to start removing characters at the first or second character.
Scoring criteria (...
12
votes
10
answers
841
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
11
answers
1k
views
Quote-Safe Quines
Your task is simple: write a program (or function) that takes no input and outputs (or returns) its source code. The catch is that when the program is wrapped in ...
39
votes
29
answers
4k
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 ...
108
votes
36
answers
12k
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 permutations.
Choose your ...
40
votes
12
answers
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 \$...
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 ...
10
votes
5
answers
451
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
...
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 ...
38
votes
14
answers
3k
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. ...