Skip to main content

Questions tagged [source-layout]

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

Filter by
Sorted by
Tagged with
7 votes
10 answers
1k views

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 ...
Thunda's user avatar
  • 1,209
25 votes
14 answers
3k views

In this challenge we try to solve two important problems at once. They are: Given integers \$a\$ and \$b\$, tell if \$a^b-1\$ is a prime number. Given integers \$a\$ and \$b\$, return \$a\choose b\$. ...
fergusq's user avatar
  • 5,157
36 votes
5 answers
1k views

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

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: ...
Emond's user avatar
  • 343
25 votes
11 answers
1k views

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 ...
Esolanging Fruit's user avatar
16 votes
15 answers
3k views

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 ...
Wheat Wizard's user avatar
  • 103k
35 votes
17 answers
3k views

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 ...
Wheat Wizard's user avatar
  • 103k
6 votes
1 answer
315 views

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 ...
user avatar
19 votes
10 answers
1k views

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 ...
clismique's user avatar
  • 7,000
10 votes
2 answers
897 views

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 ...
clismique's user avatar
  • 7,000
80 votes
16 answers
6k views

Scenario One of your friends is struggling on a homework assignment. He needs a simple program which prints the first 404 natural numbers: ...
FlipTack's user avatar
  • 14.7k
111 votes
36 answers
12k views

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 ...
Calvin's Hobbies's user avatar
32 votes
20 answers
2k views

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 ...
Martin Ender's user avatar
42 votes
19 answers
4k views

Write a program with the following properties: When run as-is, the program produces no output (i.e. 0 bytes of output). There is a location within the program (of your choice: it could be at the start,...
user avatar
8 votes
10 answers
508 views

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 ...
FinW's user avatar
  • 507
15 votes
2 answers
5k views

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 ...
clismique's user avatar
  • 7,000
27 votes
2 answers
890 views

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-...
Dennis's user avatar
  • 212k
171 votes
6 answers
19k views

Write a program that takes in a number N from 1 to 9 inclusive. In its native form your program should output N+N. E.g. output 2 if N is ...
Calvin's Hobbies's user avatar
0 votes
1 answer
511 views

Much like this challenge, write a program or function that takes no input and prints or returns the string Hello, Earth! with an optional trailing newline. The ...
Calvin's Hobbies's user avatar
21 votes
2 answers
678 views

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 ...
NonlinearFruit's user avatar
17 votes
15 answers
2k views

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. ...
Calvin's Hobbies's user avatar
12 votes
2 answers
541 views

A right-truncatable prime is a prime where every prefix is a prime (in base 10). A left-truncatable prime is exactly the opposite, where every postfix is a prime (primes that start with 0 aren't ...
Nathan Merrill's user avatar
15 votes
3 answers
3k views

Write a program using only printable ASCII characters that takes no input. For reference, here are the 95 printable ASCII characters in order: ...
Calvin's Hobbies's user avatar
17 votes
7 answers
1k views

Write some code that acts as a cat program. That is, to input a string and output it as is. But the normal reversion of your code must output the normal reversion of the input string. And the visual ...
jimmy23013's user avatar
  • 37.4k
48 votes
3 answers
4k views

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 ...
Calvin's Hobbies's user avatar
16 votes
13 answers
2k views

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!" ...
ericw31415's user avatar
  • 2,300
13 votes
21 answers
1k views

Your objective is to write a program that takes an input, and, when chained together N times, performs "sequential multiplication". What is sequential ...
Seadrus's user avatar
  • 1,403
32 votes
19 answers
3k views

Wouldn't it be neat if programming functions could be inverted, just like the mathematical function they implement? Write a function (or program) that takes one input ...
Drathier's user avatar
  • 1,859
7 votes
3 answers
208 views

The basic idea is to write a program that twists itself, and the twisted version untwists itself. The first program will just be the twisting algorithm described here, and when given its own source ...
J Atkin's user avatar
  • 5,091
31 votes
9 answers
7k views

Your job is quite simple, write a program that prints Hello, world!, that when twisted creates a program that prints Twister!. ...
J Atkin's user avatar
  • 5,091
21 votes
2 answers
549 views

Your task is to compile regexes... by specifying a substitution for each character in a regex. Regexes The regexes support these ...
Xwtek's user avatar
  • 2,049
21 votes
3 answers
2k views

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 ...
intrepidcoder's user avatar
18 votes
4 answers
1k views

(This is a variation on Print a Negative of your Code, which I enjoyed a lot! Thanks to Martin Büttner♦ - almost all of this text is his.) Let's consider the symbols to be the following printable ...
Luke's user avatar
  • 5,411
29 votes
9 answers
3k views

mbomb007 asked us to make a self mutilating program. Its an interesting challenge, but I personally don't like to encourage my programs to be self-mutilating. I like to think that, at the heart of ...
Cort Ammon's user avatar
14 votes
17 answers
2k views

Simply put, your goal is to create a complete program that modifies its own source code until every character of the source is different than what it started as. Please include the beginning source as ...
mbomb007's user avatar
  • 23.6k
31 votes
65 answers
4k views

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 ...
user avatar
30 votes
8 answers
3k views

Write two triangle (i.e. pyramid) shaped programs. The first one should be an upwards pointing text triangle with a minimum base width of three characters. So it would have a structure like ...
Calvin's Hobbies's user avatar
17 votes
5 answers
1k views

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 the ...
user avatar
44 votes
34 answers
5k views

This is a simple challenge: Given a sequence of integers, find the sum of all integers in it. But with a twist. Your score is the Levenshtein distance between your code and the following phrase (The ...
user avatar
43 votes
8 answers
6k views

There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid: This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for the 40 ...
Calvin's Hobbies's user avatar
26 votes
7 answers
2k views

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 ...
CJ Dennis's user avatar
  • 4,296
32 votes
8 answers
4k views

There are 95 printable ASCII characters: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ In the ...
Calvin's Hobbies's user avatar
33 votes
11 answers
2k views

...at least for some definition of "self-modification". The Task In this challenge, your task is to write three strings A, B ...
Zgarb's user avatar
  • 43.2k
16 votes
5 answers
559 views

You should write a program or function which outputs or returns as much of Chapter I of The Little Prince as it can. Your program or function has to be an M-by-N block of code containing only ...
randomra's user avatar
  • 20.9k
35 votes
3 answers
3k views

In the game Tetris, there are 7 types of bricks or Tetriminoes, which are mathematically known as tetrominoes because they are all made with 4 square segments: The have the names I, J, L, O, S, T, and ...
Calvin's Hobbies's user avatar
13 votes
8 answers
554 views

Write a square block of code that is N characters wide and N characters tall, for some positive integer N. For instance, your N may be 5 and the block look like this: ...
Calvin's Hobbies's user avatar
27 votes
6 answers
3k views

Here's a pixelated 5 by 7 font for the digits 0 through 9: ...
Calvin's Hobbies's user avatar
48 votes
16 answers
6k views

Write a rectangular block of text that when arranged into a Sierpinski carpet, using same-sized blocks of spaces for the empty portions, creates a program that outputs the iteration number of the ...
Calvin's Hobbies's user avatar
21 votes
12 answers
2k views

The English language and most programming languages are written and read from left-to-right, top-to-bottom, but that needn't be the case. In fact for the block of text ...
Calvin's Hobbies's user avatar
34 votes
9 answers
5k views

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 ...
Ypnypn's user avatar
  • 10.9k