Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [source-layout]

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

12
votes
21answers
2k 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
8answers
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 ...
11
votes
9answers
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 ...
36
votes
16answers
3k 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
7answers
4k 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 ...
25
votes
13answers
2k 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
28answers
4k 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] \...
25
votes
25answers
2k views

Detect Perfect Pairings

Let's have a function \$f\$ that takes a string and removes all pairs of adjacent identical characters. For example \$f(a\color{red}{bb}ba\color{red}{cc}) = aba\$ Note that when two pairs overlap ...
18
votes
21answers
2k 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 ...
25
votes
19answers
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 ...
19
votes
3answers
363 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
6answers
398 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 ...
10
votes
10answers
762 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
9answers
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 ...
44
votes
43answers
4k 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 ...
7
votes
2answers
559 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
4answers
872 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 ...
28
votes
18answers
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
8answers
435 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 ...
43
votes
18answers
5k 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
7answers
1k 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 ...
29
votes
27answers
2k 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 ...
18
votes
20answers
2k 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 ...
38
votes
22answers
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 ...
-8
votes
29answers
523 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, ...
7
votes
7answers
313 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 ...
0
votes
33answers
2k 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 ...
36
votes
18answers
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 ...
7
votes
4answers
658 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
7answers
753 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 ...
7
votes
27answers
2k views

Square and square

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 ...
24
votes
23answers
1k 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 ...
34
votes
18answers
5k 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 even ...
104
votes
123answers
15k 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 ...
1
vote
9answers
129 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 ...
16
votes
17answers
2k 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
0answers
92 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 ...
21
votes
6answers
582 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 ...
125
votes
71answers
15k 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
28answers
2k 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 ...
8
votes
6answers
899 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 ...
65
votes
5answers
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 ...
72
votes
45answers
6k 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 ...
7
votes
10answers
1k views

Break my source file! [duplicate]

Challenge Create a program that, when run, changes the contents of the source file. This means that you can delete/add/change characters in the source file, but you can't delete the (source) file ...
23
votes
14answers
3k views

Reuse your code!

In this challenge we try to solve two important problems at once. They are: Given integers a and b, tell if ab-1 is a prime number. Given integers a and b, return nCr(a, b). Specifically, you must ...
35
votes
5answers
945 views

Letter, Number, Symbol, Space, Repeat

There are 97 ASCII characters that people encounter on a regular basis. They fall into four categories: Letters (52 total) ...
24
votes
16answers
2k views

Running Merge Conflict

When using a tool such as git to merge two files, a conflict could be detected and added to the result of the merge. A merge of these two files: my file: ...
16
votes
15answers
2k views

Hidden Inversions (Robbers' Thread)

This is a cops-and-robbers puzzle, the cops' thread can be found here. Your task will be to find an anagram of the provided programs in the cops' thread that performs its left inverse. Once you ...
35
votes
17answers
3k views

Hidden Inversions (Cops' Thread)

This is a cops-and-robbers puzzle the robbers' thread can be found here. Your task will be two write two programs (or functions) such that they are anagrams of each other and one performs the left ...
5
votes
1answer
252 views

Shrink your language's character set [duplicate]

We often get restricted-source questions here on PPCG that favour submitting solutions using only a subset of characters (sufficiently so that there's a tag printable-ascii that identifies a ...