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
108
votes
104answers
13k 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 ...
206
votes
371answers
49k 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 ...
8
votes
2answers
209 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 ...
1
vote
1answer
82 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 ...
62
votes
106answers
11k 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 ...
32
votes
21answers
3k 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 ...
112
votes
53answers
34k 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 ...
12
votes
9answers
965 views

The longest period iterating quine

As we know, a quine is a program that outputs its own source code. However, it's also possible to write a program that outputs another, different program, that outputs the first program again. For ...
56
votes
65answers
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 ...
-3
votes
2answers
287 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 ...
14
votes
11answers
2k views

Double-duty quine: quine!dlroW ,olleH

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!" ...
68
votes
25answers
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 ...
9
votes
2answers
344 views

Create a Muriel-like language and implementation

Muriel is a language where the only way to loop is to create a quine and execute it. Your job is to create your own language with this property and an implementation of it in a pre-existing language. ...
18
votes
13answers
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: ...
15
votes
23answers
1k 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, ...
16
votes
11answers
2k views

Compress your code in an image

This is a quine variation. Introduction We all write short code, because some obscure reasons, but whatever we do, the'll take up at least 144 pixels/byte (with a 12px font). But what would happen, if ...
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 your ...
44
votes
28answers
5k 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 ...
23
votes
11answers
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.
33
votes
13answers
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 ...
62
votes
40answers
5k 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 ...
-1
votes
1answer
177 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: ...
23
votes
1answer
831 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 ...
23
votes
12answers
5k views

Assembly Language Quine

Write the shortest possible assembly-language quine. Use any ISA you want, unless it has a print-quine instruction or equivalent. Examples include x86, MIPS, ...
43
votes
15answers
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/...
38
votes
16answers
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 ...
7
votes
3answers
769 views

Compiled quine variant

Thinking about various quine puzzles here, I got an idea for another one: Compose a program that outputs its own compiled code to a file (or multiple files, if the compiled code is). (This means that ...
16
votes
5answers
640 views

Quining a Pristine World

This challenge is based off of Helka Homba's question Programming a Pristine World. From that question, the definition of a pristine program is: Let's define a pristine program as a program that ...
18
votes
9answers
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 ...
25
votes
41answers
3k views

Golf an Anagram Quine

In this question I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the ...
16
votes
7answers
1k views

Fibonacci program lengths

Write a program with length n that outputs another program whose length is the next Fibonacci number after n. The new program must do the same thing - output another program whose length is the next ...
37
votes
14answers
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
8answers
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 ...
6
votes
4answers
852 views

Quit Whining; Start Quining

Goal: Write a function or program that, given an integer n, will output a program in the same language that is a quine with a period of ...
2
votes
0answers
75 views

Selfish Programs [duplicate]

The Challenge Write two programs P and Q such that: P and ...
0
votes
0answers
115 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: ...
45
votes
26answers
3k 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 ...
71
votes
45answers
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 ...
4
votes
2answers
179 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 ...
21
votes
15answers
5k views

“Hello world” that creates a different “Hello world” program

Create a program, that outputs a hello world string ("Hello world", "Hello, World" etc.), and source code. Output is written to stdout or equivalent. Hello world string is embedded in the source code. ...
30
votes
30answers
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 ...
-1
votes
1answer
199 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 ...
11
votes
4answers
364 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 ...
85
votes
67answers
14k 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 ...
1
vote
20answers
509 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 ...
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 ...
20
votes
49answers
2k views

Code point sum quine

All the quine challenges on this site are focused on byte count, or the characters themselves. This one is different. Your challenge is to write a program that produces output which has a code point ...
22
votes
4answers
1k views

Cryptographic quine variant

Create a program that prints the MD5 sum of its source in the form: MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx No cheating - you can't just read ...
7
votes
1answer
827 views

Build a Twitter-quine

A short while, ago, @daniel_ernston sent the following challenge to @StackCodeGolf on Twitter: @StackCodeGolf Your task is to build a program that uses the API of your choice to tweet its own ...
9
votes
6answers
759 views

Backwards and forwards polyglot quine!

You must make a polyglot that outputs its source code in one language and its source code backward in another. Unlike the normal rules, you are allowed to read the current file or use a builtin to get ...

1
2 3 4 5