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
32 votes
30 answers
2k views

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

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 ...
Calvin's Hobbies's user avatar
4 votes
0 answers
101 views

You just have to ouput exactly all the numbers from 1 to 10 separated by spaces. Your programme should work all the times even if a random character is deleted before compiling/interpreting. This is ...
Caridorc's user avatar
  • 2,406
18 votes
36 answers
5k views

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 ...
Martin Ender's user avatar
11 votes
5 answers
708 views

Write two code fragments, which we will call s_zero and s_one. Program (l, n) consists of l copies of s_zero and s_one corresponding with the digits of n in binary, padded with s_zero on the left. ...
QuadmasterXLII's user avatar
13 votes
7 answers
1k views

Using one programming language write 5 single-line programs, each of which outputs a different line of the first verse to Harry Nilsson's 1972 song "Coconut" when run individually: Brother ...
Calvin's Hobbies's user avatar
1 vote
4 answers
582 views

All those questions that are duplicates... Ignored and marginalized by society. It is just not... right. We have to do something. There surely must be love for them too. They feel appreciated if a ...
bolov's user avatar
  • 475
7 votes
3 answers
623 views

This question is inspired by retrograde music. Retrograde music is a piece of music that can both be played normally (from the beginning to the end) as reversed (from the end the beginning). A similar ...
Def's user avatar
  • 642
13 votes
1 answer
874 views

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 ...
Calvin's Hobbies's user avatar
13 votes
1 answer
352 views

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 ...
jimmy23013's user avatar
  • 37.4k
22 votes
9 answers
2k views

The Caesar Cypher is a very simple substitution cypher where each letter is shifted by a fixed offset (looping around Z to A). Similarly, we can also a Caesar cypher for the set of printable ASCII ...
Martin Ender's user avatar
55 votes
24 answers
7k views

We define whitespace to be any of the three characters, tab (0x09), newline (0x0A) or space (0x20). For this challenge, you're to write two programs or functions in the same programming language, ...
Martin Ender's user avatar
27 votes
7 answers
2k views

This was inspired by Print a Negative of your Code and Golf a mutual quine. Consider a rectangle of characters, that meet the following restrictions: Consists solely of printable ASCII characters ...
es1024's user avatar
  • 9,185
105 votes
30 answers
16k views

Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6): ...
Martin Ender's user avatar
20 votes
4 answers
2k views

Objective Write a routine that accepts a string of printable ASCII characters, s, and returns a string containing the same characters as s, reordered so that no two-character substring appears more ...
COTO's user avatar
  • 3,681
25 votes
7 answers
3k views

Using only printable ASCII (hex codes 20 to 7E), write a square N×N core program without comments that is surrounded by 4 more layers, creating a (N+8)×(N+8) square program (N > 0). For N = 3 the ...
Calvin's Hobbies's user avatar
19 votes
3 answers
2k views

Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the ...
Martin Ender's user avatar
11 votes
5 answers
770 views

This is the companion question for Code Crosswords. Robber answers go here. See Where should we put robbers? for meta-info.
Calvin's Hobbies's user avatar
23 votes
7 answers
3k views

This is a cops-and-robbers challenge. Answer here if you are a cop (crossword maker), answer the companion question if you are a robber (crossword solver). You may take on both roles. Cops (Puzzlers) ...
Calvin's Hobbies's user avatar
34 votes
18 answers
5k views

In traditional Tetris, there are 7 distinct tetromino bricks, each denoted by a letter similar to its shape. ...
Calvin's Hobbies's user avatar
24 votes
5 answers
2k views

Consider a square block of text, N characters wide by N tall, for some odd integer N greater than 1. As an example let N = 5 and the text be: ...
Calvin's Hobbies's user avatar
10 votes
4 answers
948 views

Let's try this again. The object of this contest is to make two pieces of code that are anagrams of each other (the two must contain the same bytes in a different order), and they will do the ...
Josiah Winslow's user avatar
2 votes
3 answers
305 views

This is my first contest, so please tell me what I can do to improve. The object of this contest is to write program lines in your language of choice that are both valid code and self-descriptive in ...
Josiah Winslow's user avatar
27 votes
5 answers
2k views

A radioactive quine is a quine-like program that has an even number of characters and, when run, outputs itself with exactly half of its characters removed. The output itself may be a radioactive ...
Calvin's Hobbies's user avatar
23 votes
7 answers
2k views

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 ...
Calvin's Hobbies's user avatar
48 votes
3 answers
5k views

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, ...
Calvin's Hobbies's user avatar
29 votes
33 answers
5k views

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 ...
Calvin's Hobbies's user avatar
47 votes
14 answers
7k views

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 ...
Calvin's Hobbies's user avatar
68 votes
36 answers
8k views

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 ...
Calvin's Hobbies's user avatar
5 votes
1 answer
873 views

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 ...
Christopher King's user avatar
28 votes
12 answers
3k views

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 (...
Jwosty's user avatar
  • 3,594
10 votes
5 answers
1k views

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: ...
devnull's user avatar
  • 1,601
64 votes
44 answers
10k views

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. ...
TheDoctor's user avatar
  • 8,003
19 votes
15 answers
2k views

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 ...
jawns317's user avatar
  • 1,182
29 votes
13 answers
2k views

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 ...
jawns317's user avatar
  • 1,182
20 votes
21 answers
2k views

Your task is simple. The program reads in a line of text from the standard input, and it prints out the same text in a character-reversed form. It is not allowed to print anything else. For example: ...
vsz's user avatar
  • 8,143
14 votes
7 answers
1k views

This anecdote contains the following intriguing exchange: "Fine, Fred," Avi interrupted. "Then how would you change this to avoid duplicate entries?" "Oh, just change that one there to a ...
histocrat's user avatar
  • 22.3k
87 votes
20 answers
8k views

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

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 ...
Griffin's user avatar
  • 4,785
30 votes
4 answers
2k views

A rotation of a string is made by splitting a string into two pieces and reversing their order, for example "world!Hello, " is a rotation of ...
Gordon Bailey's user avatar
128 votes
21 answers
19k views

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 ...
Vilx-'s user avatar
  • 1,641