Questions tagged [source-layout]
For challenges that involve the physical layout or physical manipulation of source-code.
191 questions
58
votes
72
answers
12k
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 (...
13
votes
5
answers
557
views
Reverse your code, reverse the OEIS
The task here is to write a program that takes an natural number, \$n\$, and produces the \$n\$th term of an OEIS sequence. That sequence should have an identifier in the form of ...
14
votes
2
answers
833
views
Error-detecting Self-repairing Program
Your task is to create a program where if any one character is deleted, it will detect which character was deleted and then re-insert the deleted character in its own source file.
For instance, if ...
41
votes
13
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 \$...
9
votes
13
answers
753
views
Just Twice Is Nice
Let's have string multiplication to take a string and a positive number and concatenate that string that many times. In Haskell:
...
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
8
answers
1k
views
Backhanded Compliments
This challenge is created in celebration of my first esoteric language, Backhand!
Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only ...
12
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 ...
50
votes
24
answers
4k
views
A Chiral Puzzle
A shape is chiral if no amount of rotation can make it look like it's mirror image. In this puzzle we will be writing chiral computer programs.
For this puzzle we will think of a program as a ...
31
votes
8
answers
5k
views
What did we forget?
Your task is to write a non-empty computer program comprised of some sequence of bytes. If we choose a particular byte in the program and remove all instances of it from the program, the modified ...
39
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. ...
37
votes
28
answers
5k
views
Is the matrix centrosymmetric... and so is the code?
Defintion
A centrosymmetric matrix is a square matrix that is symmetric about its center. More rigorously, a matrix \$A\$ of size \$n \times n\$ is centrosymmetric if, for any \$i,\: j \in ([1, n] \...
33
votes
17
answers
5k
views
2 Cats in a Quine
Challenge
Make two programs, A and B, which are both cat programs in the same language. When concatenated, AB (also in the same language) should be a quine.
For example, suppose ...
19
votes
22
answers
3k
views
The repetitive byte counter
Your task is to write a non-empty program / function of byte count L, which, when repeated M times, checks whether a given positive integer N is equal to L × M.
You should, in theory, support an ...
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 ...
22
votes
5
answers
542
views
Swap program halves to test divisors
Four integer sequences
In this challenge, you will test four different properties of a positive integer, given by the following sequences.
A positive integer N is
perfect (OEIS A000396), if the sum ...
10
votes
6
answers
537
views
Self-Validating Triangular Checkerboard Program
A checkerboard program is a program where each individual character's ordinal value alternates from even to odd, excluding the line terminator (which can be any standard line-endings).
A triangular ...
11
votes
11
answers
1k
views
N times program for the N-th number
Given an array of positive integers A as the input, generate a program that, when repeated for k times, output the ...
41
votes
9
answers
5k
views
Shifting-Oriented Programming
A string can be shifted by a number n by getting the byte value c of each character in the string, calculating ...
51
votes
51
answers
5k
views
Third time the charm
Your task, if you wish to accept it, is to write a program that outputs a positive integer (higher than 0). If the source code is duplicated the output must remain the same. The tricky part is that if ...
11
votes
2
answers
5k
views
Creating a function over multiple lines
I'm attempting to create a function over multiple lines.
Parameters of the challenge:
Function returns 'barbarian'
Only 2 characters per line
40 lines maximum.
I keep trying to use a fat arrow to ...
18
votes
4
answers
977
views
Build a half cardinal cyclic quine
A half cardinal cyclic quine is a cyclic quine with two states, one perpendicular to the other.
Rules
You can decide which rotation you want to implement, clockwise or counter-clockwise.
Once ...
30
votes
18
answers
5k
views
Take a stand against long quine lines
or: Build a vertical quine
Inspired by Take a stand against long lines.
Your task is to build a vertical quine with as short a line length as possible.
Scoring
Shortest line length (excluding ...
14
votes
8
answers
579
views
Deranged Rearrangements
Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n ...
45
votes
20
answers
6k
views
Create a square of increasing size by replicating the initial code
Your assignment is to write a program of even length, that prints an ASCII-art square (described below), that increases its side length by 1 unit each time the original source code is pasted in the ...
18
votes
8
answers
2k
views
Russian Nesting Quine
A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller ...
35
votes
21
answers
4k
views
Longest Non-Repeating Substring
Given a string as input find the longest contiguous substring that does not have any character twice or more. If there are multiple such substrings you may output either. You may assume that the ...
30
votes
28
answers
3k
views
Concatenative counting
Your challenge is to write N snippets of code such that, when you concatenate the first K ≥ 1 together, they produce the number K. The higher N, the better. Here's the catch: you may not use any ...
19
votes
21
answers
3k
views
Find the Needle in the Haystack (Robbers)
This is part of a cops-and-robbers challenge. Go here for the cops' part.
The Robbers' Challenge
A cop's answer can be cracked by removing any subset of characters from the Haystack program, so that ...
41
votes
25
answers
5k
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 ...
-9
votes
29
answers
933
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, ...
8
votes
7
answers
419
views
Twice as long, half the price [duplicate]
Related: I double the source, you double the output!
When Steve Jobs launched the iPhone 3G, the slogan said
Twice as fast, half the price
I changed the word fast to long to better represent this ...
4
votes
34
answers
3k
views
Code 3k to Codee k
Write some code...
Write a program that takes no input and outputs an integer n which is a multiple of 3. So ...
40
votes
20
answers
4k
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 <...
6
votes
4
answers
723
views
Unfurling-Safe Quine
Write a proper quine containing at least one newline/linefeed whose every unfurling is either itself a proper quine or outputs the original quine. Your answer can mix and match outputting itself and ...
9
votes
7
answers
924
views
Code-Golf Assembly Line
Note: This challenge has nothing to do with actual assembly language.
As the head of Code-Golf Factory Inc., you must create an assembly line to generate a specific piece of code. Today, the foreman ...
9
votes
32
answers
2k
views
Square and square [closed]
Squares looks symmetric, and so are the required codes.
Objective: Write a program whose source code is a solid square (N lines with N printable, non-whitespace characters each line) and prints a ...
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 ...
40
votes
29
answers
6k
views
Double-time is not double time
Based on this challenge.
In the rhythm game osu!, the difficulty modifier "Double-time" actually only increases the speed by 50%.
Your task, is to write a program that outputs a positive ...
1
vote
9
answers
279
views
Given a string and integer n, split the string at n characters, and print as follows: [duplicate]
Given a string and integer n, split the string at n character, and print as follows:
Ex)
laptop 3 should print lap top
...
22
votes
22
answers
3k
views
"Hello, World!" (Every other character, Part 2)
As a kind of part 2 to Hello, World! (Every other character), write a program such that all three of these programs print "Hello, World!": the entire program, the 1st, 3rd, 5th, etc. characters of ...
6
votes
0
answers
114
views
Every Nth Char in Source Outputs N [duplicate]
Heavily inspired by Hello, World! (Every other character)
Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs ...
23
votes
6
answers
874
views
Transposes and Diagonals
For this challenge, you should write a program or function which outputs the diagonals of a given square matrix. However, if you transpose the rows and columns of your solution's source code, it ...
146
votes
92
answers
25k
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 ...
23
votes
28
answers
3k
views
Take a stand against long lines
Recently, someone proposed more stringent limits for Python's default line length:
Clearly, no program should ever use more than 80 characters per line, for a whole host of reasons. First and ...
10
votes
5
answers
2k
views
It's Anagram Quine, not just Quine!
The Task
In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible.
Your score will be the number of anagrams of your ...
69
votes
6
answers
5k
views
Powerprogramming: O(1^N), O(N^1), O(2^N), O(N^2) all in one
Write a program (or function) that exhibits four common big O time complexities depending on how it is run. In any form it takes in a positive integer N which you may assume is less than 231.
When the ...
88
votes
64
answers
8k
views
From Programming Puzzles to Code Golf
Your task is to write a program that outputs the exact string Programming Puzzles (trailing newline optional), but when all spaces, tabs, and newlines are removed ...