Questions tagged [source-layout]
For challenges that involve the physical layout or physical manipulation of source-code.
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 ...
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 ...
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 ...
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 ...
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. ...
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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. ...
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 ...
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!" ...
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 ...
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 ...
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 <...
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 ...
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 ...
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 ...
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 ...
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 ...
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-...
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-...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 \$...
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 ...
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 ...
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 ...
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. ...