Questions tagged [quine]

A quine is a program which produces its source as output. This tag indicates that the challenge is related to quines.

Filter by
Sorted by
Tagged with
203
votes
322answers
42k views

Golf you a quine for great good!

Using your language of choice, golf a quine. A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output. No cheating -- that means ...
108
votes
45answers
31k views

Program that creates larger versions of itself (quine-variant)

You are to write a program that will output source code that is Larger than the original program (character wise) Will print another program larger than itself when run (i.e. the new program is also ...
102
votes
96answers
11k views

Make an error quine!

Your challenge: write a "program", for a language of your choice, that causes the compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your ...
100
votes
25answers
15k views

Print a Negative of your Code

Consider a square of printable ASCII characters (code points 0x20 to 0x7E) for side length N, like the following (here, N = 6): ...
82
votes
65answers
13k views

Print your code backwards - reverse quine

Write a program that prints its own source code out backwards, in other words an eniuq. Scoring: +50 if you use pull data from the Internet. +25 if you read your own source code. +1 point per ...
71
votes
27answers
6k views

2016 Time Capsule String: How Versatile Is Your Language?

About a year ago on Dec 31, 2015, I had the idea that: We should make a time capsule string. Everybody gets to add one character and next new years we'll see who can make the best program out of ...
70
votes
43answers
6k views

Input ∩ Source Code

Intro The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise: Let ...
65
votes
24answers
9k views

Write a program that downloads itself

Write a program that connects to this site, downloads the very answer in which it is posted, extracts its own source code and prints it out. The output must be identical to the source code. Shortest ...
59
votes
94answers
10k views

Print the last, middle and first character of your code

The challenge is simple: Print the last, middle, and first character of your program's source code, in that order. The middle character is defined as follows, assuming a source length of ...
54
votes
62answers
8k views

A “cheating” quine

Long-time lurker, first-time poster. So here goes. In the Wikipedia page for quine, it says that "a quine is considered to be 'cheating' if it looks at its own source code." Your task is to make one ...
53
votes
33answers
4k views

Write the shortest self-identifying program (a quine variant)

Write a program that will generate a "true" output iff the input matches the source code of the program, and which generates a "false" output iff the input does not match the source code of the ...
48
votes
5answers
1k views

TryItOnquine Challenge

(based on this post and the ensuing discussion on chat -- also, much thanks to Dennis for TIO!) The Challenge Choose a language that's currently available on the TryItOnline site, for example ...
45
votes
1answer
1k views

Cyclic Levenquine

Background As most PPCG regulars will know, a quine is a program which outputs its own source code when run; and the Levenshtein distance between two strings is the minimum number of insertions, ...
43
votes
24answers
2k views

Output the first position in your program for each input character

Challenge Write a non-empty program/function p that, given a non-empty input string s, outputs the position of the first ...
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, ...
41
votes
9answers
5k views

Write a Quine in Plain English

Write a quine that consists of real English words separated by single spaces. A "word" is defined as a string containing only lowercase and uppercase letters (...
41
votes
27answers
4k views

Self-growing code codee codeee codeeee

Write a program (or function) (let's call it P1), that when run, outputs another program P2 of the same language and exactly 1 byte longer than P1. Program P2 when run, should output a 3rd program P3 ...
39
votes
14answers
2k views

Stack Exchange Vote Counter

Write a program/function that returns the vote count of its own Stack Exchange answer at the time of its execution. Your program/function may access this page (codegolf.stackexchange.com/questions/...
39
votes
3answers
4k views

Radiation Hardened Quine

As you should (hopefully) know, a radiation hardened quine is a quine that you can remove any one character from and still print its original, pre-modified source. The thing is, with most of these you ...
38
votes
13answers
4k views

Golf a mutual quine

Using two languages of your choice, write the smallest “mutual quine” you can. That is, write a program P in language A that outputs the source code for a program Q in language B, such ...
38
votes
9answers
2k views

Make a slow error quine maker!

As part of his answer to Make an Error Quine!, @Falko proposed the following algorithm: How to create your own solution in 2 minutes? Open a new file in an IDE of your choice. Bang your ...
35
votes
2answers
1k views

Radiation softened quine

It's simple: Make a proper quine where if you remove any character, it's still a quine. The difference between this and a radiation hardened quine is that if your program is ...
34
votes
13answers
3k views

1-up your average quine

A 1-up quine is a program which is very similar to a quine. The one major difference is that instead of printing itself once, when n copies of the program are concatenated, the result prints the ...
33
votes
20answers
2k views

Write a Polyquine

A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins. 1 I made that up. Or ...
33
votes
11answers
2k views

Multiplication by Self-Modification

...at least for some definition of "self-modification". The Task In this challenge, your task is to write three strings A, B ...
32
votes
7answers
2k views

Newtons Method by Recursive Quines

Your task is to calculate the square root of 2 using Newton's Method - with a slight twist. Your program is to calculate an iteration using Newton's Method, and output the source code for the ...
32
votes
6answers
2k views

Mirror quine (or my head hurts)

I was reading Print your code backwards - reverse quine And I thought, this could be more interesting if your backwards code is also executable. So this challenge will have all the rules and ...
32
votes
7answers
1k views

Three polyglots, two period-two quines, and one code-golf challenge

Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C. Program B, when run in language B produces Program A, and running ...
31
votes
14answers
4k views

2 Cats in a Quine

Challenge Make two programs, A and B, which are both cat programs in the same language. When concatenated, AB (also in the same language) should be a quine. For example, suppose ...
31
votes
6answers
3k views

Make the largest infinity that you can!

The ordinal number system is a system with infinite numbers. A lot of infinite numbers. So many infinite numbers that it literally does not have an infinity to represent its own infiniteness. The ...
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 ...
30
votes
12answers
2k views

Write a Quine Suite

We've had a lot of quine challenges, but a lot of the quine formats are similar, lets create some variance in our quines. Your task is to create a selection of programs in the same language (at least ...
30
votes
29answers
2k views

A Quine on Every Line

Your goal is to create a program that prints itself indefinitely, with a new line after each one. Thus, if your program is a one-liner, it would be repeated on every line of the output. Example ...
30
votes
7answers
2k views

Tips for writing quines

A quine is a program that produces output that's identical to the program's source code. On this website, we generally only care about proper quines (at the time of writing, the current definition is "...
30
votes
8answers
2k views

A Fragile Quine

A Fragile Quine A fragile quine is a quine that satisfies the property of having each substring made by removing a single character, when evaluated, produces an error. For example. If your program <...
30
votes
7answers
1k views

Slow growing Quine

Make a Quine. Seems easy right? Well this quine must output itself plus its first character, which then outputs itself plus its second character, and so on. This way the quine should in several ...
30
votes
1answer
2k views

Confound my attempts to solve the halting problem

Please note: By its nature, the spec for this challenge is difficult to understand. It probably requires at least a freshman course in computability theory, or equivalent background reading. In ...
29
votes
16answers
5k views

Output an image of your source code (not-quite-a-Quine)

Code golf: Print an image of the source code. Requirements Must output the image of the source code itself, not a version stored elsewhere and retrieved at run time. Code must be legible enough to ...
29
votes
18answers
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 ...
29
votes
20answers
4k views

Interquine - Two programs that output each other in a loop

Program A outputs program B's code when run, and B outputs A's source. Requirements: Only one language across both programs Programs are different. One program that outputs itself does not qualify. ...
29
votes
17answers
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 ...
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 ...
27
votes
6answers
957 views

Mutually Exclusive Quines

Your challenge is simple. Write two programs that share no characters which output each other. Example Two programs P and Q are mutually exclusive quines if: P outputs Q Q outputs P There is no ...
27
votes
5answers
2k views

Radioactive Quines

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 ...
27
votes
2answers
724 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-...
26
votes
12answers
1k views

Quine / Reverse Quine

Write a complete program that takes a boolean or non-negative integer input. It must: Output its own source code if the input value is falsy Output its own source code in reverse if the input value ...
26
votes
2answers
1k views

Fastest Mini-Flak Quine

Mini-Flak is a subset of the Brain-Flak language, where the <>, <...> and [] ...
26
votes
11answers
1k views

Anagram Quines (Cops' Thread)

This is a cops-and-robbers challenge the Robbers' Thread can be found here Your challenge is to write a program that outputs an anagram of its source code but not the original source code itself. ...
26
votes
2answers
585 views

Lipogram “quine”

Task Take a single Unicode character as input. Output a program in the same language that also obeys this specification, but which does not contain the input character. If your program is run with ...
26
votes
3answers
631 views

Mutant pangolin

This is a code-golf challenge whereby you need to devise a program that acts like a quine or a quine that modifies itself to illustrate machine learning. Background There is a basic artificial ...