Questions tagged [quine]
A quine is a program which produces its source as output. This tag indicates that the challenge is related to quines.
264
questions
4
votes
1
answer
78
views
I reverse the source code, you reverse the source code! [duplicate]
Write a program that outputs its source code in reverse when run, and outputs its source forwards when I reverse the source. If your program is "abcd", when run with no arguments it should ...
11
votes
4
answers
205
views
Print the answer before a given answer
In this challenge, you'll take an answer as input, and print the answer before it. If the answer passed as input is the first answer, print your own submission's source. You'll be passed any answer in ...
0
votes
0
answers
69
views
A quine in WebAssembly? [duplicate]
I couldn't find one online, so here's a fairly trivial challenge: write a quine in WebAssembly text format (there's actually at least one in Wasm binary format).
(Edit: the suggested post is probably ...
5
votes
9
answers
1k
views
Write a program that prints a program that's almost quine
Your task is to make a program in L that takes n as an input number, output a program p in <...
13
votes
10
answers
1k
views
Lexicographically self-comparing code
This is a quine challenge related to Write the shortest self-identifying program (a quine variant)
Write a function or a full program that compares lexicographically its source code and input, that is,...
25
votes
8
answers
2k
views
Write some Genetic Quines
In this challenge, you'll create some programs which behave similarly to genes. When you run one, it will return one of its two "alleles" (a half of its source code), and concatenating any ...
12
votes
8
answers
1k
views
Iterative Quine
Create a program which prints itself, followed by an additional program. This additional program should print the first program, itself, and then a third program. This continues until the nth program, ...
10
votes
0
answers
420
views
Jelly compression quine
The golfing language Jelly has a very complex and clever string compression system which I'm not going to go into depth about here. You can find a very good explanation here.
Basically, Jelly's string ...
24
votes
4
answers
2k
views
A quantum quine
Your challenge is to write a program that is a quine, meaning it prints out its own source code.
For at least one individual character, when it is removed from the program's source, a single different ...
9
votes
4
answers
334
views
The Roly-Poly, Square-Wheeled Quine
Code-Golf caddy Eddie Brackets was getting tired of quine challenges, which appeared to be much too easy for the grand poobahs. He has this idea to spice up things and is sending quines to the car ...
32
votes
7
answers
4k
views
I'm a lizard, cut here!
Write an \$n\$-bytes program \$AB\$ such that:
it outputs an integer \$x,\ 0\lt x\lt n\$;
both its \$x\$-byte prefix \$A\$ and \$(n-x)\$-byte suffix \$B\$, when run as programs, output \$AB\$.
\$A, ...
15
votes
9
answers
2k
views
Full name quine
Most Unicode characters have full names, for example ” is "RIGHT DOUBLE QUOTATION MARK". You can find a useful reference here, just type in the character ...
12
votes
14
answers
756
views
Minimal distinct character quine
Your challenge is to construct a proper quine using as few distinct characters as possible.
Scoring
Your score is equal to the number of distinct characters in your code, aiming to minimise this. ...
6
votes
0
answers
243
views
Build a program that outputs itself encoded as a QR [closed]
The goal is simple. Write a program that outputs itself encoded as a QR code.
A QR code is a way to encode data in a black and white image, similar to a 2D image.
An example implementation can be ...
18
votes
20
answers
2k
views
Hello, Permutations!
For this challenge, you will be required to write 3 programs:
The first program should be a quine, i.e, it should print it's own source code.
The second program should read the input and print all of ...
12
votes
3
answers
497
views
Multiplying Quines
The program should start out with 2 separate files, here named "a" and "b". "a" and "b" should be what I am calling inverse quines: "a", when run, ...
19
votes
8
answers
2k
views
(Error) quines, hello world, polyglots, oh my!
Introduction
A quine is a program that outputs its own source code. For example, a well-known Python quine is _='_=%r;print(end=_%%_)';print(end=_%_). Running it ...
1
vote
1
answer
198
views
Simple "hyena" program [duplicate]
Write a program that takes a string as an input. For the input:
If the input doesn't match the source code, the program shall output the input intact. (Hence a cat)
Otherwise, the program shall fall ...
11
votes
2
answers
439
views
Inverse quine: print everything except your program
Write a program which will eventually, given enough time, print all possible permutations of ASCII characters (both printable and non-printable) less than or equal to its length, except itself. The ...
22
votes
20
answers
2k
views
Case invert your quine
Write a quine which attempts to invert the case of as many ascii characters in the source code as possible. For example in javascript:
...
39
votes
29
answers
5k
views
Cat, Quine, Hello World
Write a cat program, a quine, and a Hello World in the same language such that when two specific programs of the three are concatenated in a certain order, you get the third program. It does not ...
-1
votes
1
answer
259
views
Format yourself for codegolf! [duplicate]
Task
Your task is to write a program that, taking no input, outputs a string that represents a formatted codegolf answer of itself. The pattern is the following:
...
20
votes
25
answers
2k
views
Counting characters
Write a function or program that accepts one character (or a string of length 1) as input, and outputs the number of times that character occurs inside the code.
This program must be a Proper Quine, ...
28
votes
1
answer
2k
views
Program that compiles into itself
We've had lots of questions about quines, programs where the source code and output are identical. For compiled languages, there are other combinations: we've already had a question about writing a ...
22
votes
11
answers
2k
views
Narcissistic Quine [duplicate]
Write a program/method that:
Becomes a quine when the input matches the source code;
Doesn't halt otherwise.
This is code-golf, so shortest solution wins. Avoid any standard loopholes.
2
votes
0
answers
83
views
Selfish Programs [duplicate]
The Challenge
Write two programs P and Q such that:
P and ...
0
votes
0
answers
232
views
What is the shortest brainfuck quine? [duplicate]
(Apart from the empty program of course)
The shortest I could find was this 410 byte beauty:
...
4
votes
2
answers
202
views
Inter-language 2-cycle quine [duplicate]
Challenge
Create 2 programs A and B
The output of program A is exactly program B
The output of program B is exactly program A
Neither program should depend on inputs to yield the correct output
A ...
33
votes
13
answers
6k
views
Write a program that sees the New Year in itself
Write the smallest program that maps strings injectively to outputs and maps itself to 2020.
To be clear, your program \$p\$ must have the following properties:
every possible input string \$s\$ has ...
0
votes
1
answer
607
views
Polyglot Iterative Quine
Introduction
A polyglot is a program that is valid in multiple languages at once. An iterative quine is a program that outputs another program that outputs another program that outputs the source of ...
13
votes
5
answers
474
views
Rock Paper Scissors (Sorta) Quine
Create three programs, which we'll call Rock, Paper, and Scissors.
Each program must be unique, and accept input.
If a program gets any input which is not one of the programs Rock, Paper or ...
1
vote
20
answers
616
views
Quine in Bytes, not Characters [duplicate]
Introduction
A quine is a program that takes no input and produces a copy of its own source code as output. Writing a quine is a standard test of a programming language. Most quines operate using ...
1
vote
0
answers
141
views
"Know Thyself" Program [duplicate]
Challenge
Write a program that takes as input a text and output "That's me!" if the input is equal to the program own source code, and "That's not me!" otherwise.
Notes
This is codegolf, in each ...
19
votes
7
answers
3k
views
Y2K... in 2019?
It's August 10th, 2019, but your task still involves Y2K. Weird, right?
Create a program that prints itself, with a two digit number appended to it. The first time you run it, it should append 00 to ...
-3
votes
1
answer
353
views
longest ungolfable quine [closed]
Create a quine that cannot be golfed. Your score is your byte count, where higher is better. If someone finds a shorter version, their score is your original byte count, and you lose points
Scoring ...
13
votes
9
answers
2k
views
n-level Ouroboros Quine
This 128-language quine ouroboros (a program which outputs a program in another language, which outputs a program in yet another language, (125 languages later), which outputs the original program) is ...
34
votes
20
answers
3k
views
A quine of sorts
Given a string x, output the characters in x sorted according to the order of appearance in your source code.
Examples
...
7
votes
6
answers
303
views
Inverse-quotes-quine, inverted (pt. 2)
Based on a comment by Jo King on my previous question (called 'Inverse-quotes-quine'), I present this new question. The rules are similar, but just, the opposite:
If your program is run normally, all ...
31
votes
18
answers
2k
views
Inverse-quotes-quine
The prospect of this challenge is:
If your program is run normally, all of the code in the speech marks (" - double quotes) should be printed.
If your program is ...
6
votes
16
answers
791
views
The anti-narcissist
The narcissist is a program which, given its own source as input, prints a truthy value and, given anything other than that, prints a falsey value. Today, we're reversing this.
Create a program that, ...
3
votes
2
answers
770
views
A poly-moly-holy quine. (Well, it's not, but the title's cool.)
This is an answer chaining puzzle, where each answer must add on to the last.
The \$n\$th submission must output its own source code in the \$n\$th language and the \$n−1\$ languages before it.
A ...
-2
votes
5
answers
353
views
45 degree quine [closed]
A very simple golf this time, but should be fun to do.
Challenge
Output your code, but rotated 45 (or -45) degrees. E.g:
lorem ipsum dolor sit amet
becomes
<...
-2
votes
2
answers
317
views
Invert your code
Challenge
Return the full contents of your program, but inverted. How do your invert something? Well,
Letters: Take the position of the letter in the alphabet, subtract from 26, and use the letter ...
11
votes
9
answers
600
views
The Great Pyramid of Quine
The task is a rather simple quine challenge with a twist, you must output your source code in the shape of a pyramid. The shape of a pyramid is defined below:
...
24
votes
3
answers
2k
views
Meta-bowling Golf
Your task is to create the shortest program (A) that outputs another program (B) with the most unique bytes, which in turn outputs the original program (A). Essentially, you are golfing one half of a ...
18
votes
9
answers
2k
views
Write the longest period iterating quine bounded by 500 bytes
Your job is to create the longest period iterating quine, where the length of each program in the sequence is bounded by 500 bytes.
That is, if you repeat the following steps:
Start with your ...
10
votes
0
answers
579
views
Radiation is Painful
A radiation-hardened quine can take a hit and stay standing, but nobody ever said that the quine can't be a wuss about it.
For this challenge, you should write a quine that:
If no characters are ...
2
votes
0
answers
280
views
Heart-shaped quine [closed]
As you may or may not know, Valentine's day is getting close. So today, my task for you is:
Write a heart-shaped quine
Rules:
Code should look like an identifyable heart shape, i.e. Has two round ...
12
votes
15
answers
2k
views
Quine outputs itself in binary
Your task, if you wish to accept it, is to write a program that outputs its own source code in the binary UTF-8 representation.
Rules
The source must be at least 1 byte long.
Your program must not ...
5
votes
2
answers
673
views
A Multipurpose Quine
I personally love quines, but they all seem to be so... static. So why not create a quine that can do more.
Challenge
The challenge here is to create a quine that without any sort of input is a ...