Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
19
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 ...
20
votes
2answers
1k views

90° Self-Rotating Program

Introduction Write a complete program that rotates a rectangular block of ASCII characters 90 degrees clockwise. When the program itself is rotated 90 degrees clockwise, it rotates a block of ASCII ...
64
votes
24answers
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 ...
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: ...
28
votes
29answers
4k views

Program your favorite phrase

Pick a quote or phrase that is exactly 5 words long, such as Programming puzzles and code golf!. Write a program that, when appended to itself n times, outputs the ...
14
votes
8answers
446 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 ...
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 ...
129
votes
71answers
16k 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 ...
36
votes
5answers
1k 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) ...
19
votes
3answers
381 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 ...
32
votes
9answers
4k views

One hundred passwords

I have one hundred vaults, each one within another. Each vault has a password, consisting of a single number. 95 43 81 89 56 89 57 67 7 45 34 34 78 88 14 40 81 23 26 78 46 8 ...
9
votes
2answers
2k 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
886 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 ...
1
vote
33answers
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 ...
21
votes
6answers
612 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 ...
30
votes
24answers
2k views

Join N copies of a snippet to produce N^2 characters

Challenge Write the shortest snippet of code possible such that, when N copies of it are concatenated together, the number of characters output is N2. N will be a positive integer. For example if ...
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 ...
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 ...
47
votes
3answers
4k views

Coding Around The Clock

Write a single line program two or more characters long that contains no line terminators and takes no input. For example, your program might be: MyProgram When ...
9
votes
7answers
778 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
7answers
326 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 ...
37
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
669 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 ...
12
votes
1answer
745 views

Code a Code Slidey Puzzle!

The most recognizable sliding puzzle is the fifteen puzzle. It has a 4 by 4 grid, 15 tiles, and one empty grid space. The tiles can only move into the empty space and must always be in line with the ...
27
votes
2answers
753 views

Hyper about quines

Inspired by Hyperprogramming: N+N, N×N, N^N all in one. Thanks to @MartinEnder and @trichoplax for their help in the sandbox. Definitions Hyperquines Define a hyperquine of order n as a quine-...
67
votes
7answers
6k views

Fault-Tolerant Hello World (a.k.a. the Interview)

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 easy. ...
1
vote
9answers
147 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 ...
6
votes
0answers
97 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 ...
20
votes
3answers
1k views

Anagramming Stack Exchange question titles into programs

Stack Exchange currently has 134 question and answer sites. This includes all beta sites (such as PPCG) but not Area 51 proposals nor any meta sites, except for the "mother meta". To answer this ...
24
votes
7answers
2k views

XOR encrypt your programs with the source of other programs

Write two programs such that when the bytes of their source code are XOR-d together it produces a third, valid program, all in the same language. The length of each of the three programs in bytes must ...
5
votes
1answer
826 views

Let us create a sonnet quine! [closed]

There are programs that will output its source code to standard output and do nothing else. They also access no external output. This type of program is known as a quine, and is a common code ...
10
votes
5answers
1k 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 ...
66
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 ...
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 ...
43
votes
3answers
4k views

Code that runs the Game of Life on itself

Write two rectangular blocks of code, each w characters wide and h characters tall, that implement Conway's Game of Life when arranged in a grid. (w and h may be any positive integers) For example, ...
74
votes
11answers
5k views

Error 404: Character Not Found

Scenario One of your friends is struggling on a homework assignment. He needs a simple program which prints the first 404 natural numbers: ...
19
votes
2answers
509 views

Chuck Norris vs Travelling Salesman

Introduction Almost everyone is familiar with the Travelling Salesman Problem (TSP). The task is to, given a list of N cities, find the minimum Hamiltonian cycle ...
47
votes
14answers
7k views

Make a code square with your favorite word

Pick your favorite 6 letter common English word that has no repeated letters, such as wombat. Write a program in an N×N grid of characters without comments such ...
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 ...
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 ...
17
votes
15answers
2k views

Write a program that outputs the number of times it has been run [duplicate]

In a programming language of your choice, write a full program that, when run, prints a positive integer N and then modifies its own source file such that the next time it is run it will print N+1. ...
17
votes
36answers
3k views

The Jigsaw Code Puzzle

This is an answer-dependent challenge! The order of answers matters, and your exact task depends on the last answer that was posted. You might want to sort the answers by oldest. Let's piece together ...
17
votes
7answers
928 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 ...
5
votes
1answer
272 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 ...
10
votes
2answers
836 views

Positional Awareness

Positional Awareness Your task is to generate a program that, for every permutation of its characters (which includes the original program), outputs the positions of every character relative to the ...
32
votes
20answers
2k views

Figure and Ground

Source: Wikipedia For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure ...
8
votes
10answers
412 views

Make your program sequential! [closed]

Your task, if you choose to accept it, is simple. Objective You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a ...
13
votes
2answers
4k views

Primes with a twist

Note: this is heavily inspired by this question. Task: Your task is to generate the nth prime, when each character of your program is repeated ...