| Bytes | Lang | Time | Link |
|---|---|---|---|
| 029 | JavaScript V8 | 250501T234932Z | Lucenapo |
| 038 | Excel | 221102T184549Z | Engineer |
| 008 | Keg | 200214T210918Z | lyxal |
| 002 | W | 200214T150023Z | user9206 |
| 008 | GolfScript | 200214T143505Z | Mathgeek |
| 006 | Jelly | 180726T185311Z | dylnan |
| 004 | Stax | 180226T112847Z | Weijun Z |
| 008 | Microscript II | 180226T120643Z | SuperJed |
| 088 | Java 8 | 180226T103916Z | Kevin Cr |
| 031 | Python 3 | 180119T095830Z | aaay aaa |
| 004 | Python Repl | 170609T100453Z | Colonel |
| 011 | JavaScript yet another one | 170609T081706Z | GOTO 0 |
| 002 | Mathematica | 170608T141853Z | Ben |
| 008 | Retina | 170608T084247Z | Martin E |
| 032 | Braingolf | 170608T081657Z | Mayube |
| 032 | JavaScript ES6 | 170607T200129Z | Neil |
| 006 | Fission 2 | 170607T180301Z | Luke |
| 007 | Jelly | 170608T004012Z | Dennis |
| 158 | Brainfuck | 170607T215801Z | 6infinit |
| 015 | JavaScript ES6 | 170607T215110Z | Rick Hit |
| 014 | Ohm | 170607T212905Z | Datboi |
| 008 | Befunge98 | 170607T212150Z | ovs |
| 006 | CJam | 170607T210635Z | Martin E |
| 008 | QBIC | 170607T204638Z | steenber |
| 010 | 05AB1E | 170607T195921Z | Magic Oc |
| 020 | Groovy | 170607T201709Z | Magic Oc |
| 010 | str | 170607T190801Z | Conor O& |
| 032 | Python 3 | 170607T190519Z | Calculat |
| 039 | Haskell | 170607T190141Z | Laikoni |
| 011 | Befunge | 170607T185942Z | MegaTom |
| 007 | ><> | 170607T172740Z | user4180 |
| 008 | CJam | 170607T190225Z | Business |
| 044 | PHP | 170607T175119Z | Jör |
| 008 | Ruby | 170607T184416Z | Wheat Wi |
| 036 | Bash | 170607T180334Z | Doorknob |
| 009 | Japt | 170607T174845Z | ETHprodu |
| 034 | shortC | 170607T175131Z | MD XF |
| 060 | C | 170607T174755Z | MD XF |
| 013 | 05AB1E | 170607T174652Z | Riley |
| 020 | Ruby | 170607T174223Z | Doorknob |
| 004 | V | 170607T174200Z | Riley |
| 7613 | Klein | 170607T173642Z | Wheat Wi |
| 002 | Pyth | 170607T173513Z | Rod |
Excel, 38 bytes
=REPT("=REPT(CHAR(34),2)&"&CHAR(34),2)
Output is:
=REPT(CHAR(34),2)&"=REPT(CHAR(34),2)&"
If you sort and concatenate the characters from either, you get this:
""&&(((()))),,==223344AACCEEHHPPRRRRTT
W, 2 bytes
1-
Explanation
a % (Implicit) argument of the input
% The input is automatically set to 0
% if it isn't specified
1- % Minus 1 over the input (i.e. 0-1 = -1)
Output:
-1
GolfScript, 8 bytes
{}*{.*}.
Output is {.*}{.*}
Works because the first three characters are garbage to find a way to get another set of braces in the program that don't show up.
If you don't care about whitespace, then {+}{.}+. outputs {+ .}{+ .}, which was my first attempt.
Stax, 8 4 bytes
.S.S
A direct port of this answer.
Old version, 8 bytes
..b..LbL
Alternative version with a pretty cheap trick that can be applied to proper quines in almost any language.
"43bL"34bL
Because "34bL"34bL is a proper quine in Stax.
Yet another version, using only single-char string literals.
''c'Lc'cccLcLL
Explanation
.S.S Generates powerset ["","S","S.","."]
Implicit flatten and output
..b Push string ".b"
..L Push string ".L"
b Duplicate both strings
L Concatenate all 4 strings to a single one.
Microscript II, 8 bytes
"phq"pqh
Microscript, 11 bytes (also a reverse quine):
0"Caxq"Caxq
Java 8, 88 bytes
v->{String s="-v>{String s=%c%s%1$c;return s.format(s,34,s);}";return s.format(s,34,s);}
Outputs with both v and - swapped as anagram:
-v>{String s="-v>{String s=%c%s%1$c;return s.format(s,34,s);}";return s.format(s,34,s);}
Explanation:
- The
String scontains the unformatted source code (with-andvswapped to make it an anagram. %sis used to input this String into itself with thes.format(...).%c,%1$cand the34are used to format the double-quotes.s.format(s,34,s)puts it all together.
Python 3, 31 bytes
a='a=%r;pritn(a%%a)';print(a%a)
Python Repl, 4 bytes
This is my first Code Golf solution, so I hope it meets the rules. In the Python 2 or 3 interactive interpreter:
>>> (1),
(1,)
The output is an anagram of the input.
Another:
>>> 2*'2*'
'2*2*'
In Python 2:
>>> type('rst <>'),
(<type 'str'>,)
In Python 3:
>> {1, 0}
{0, 1}
Update 2017-06-15: Yet another:
>>> 01.
1.0
JavaScript (yet another one), 11 bytes
f=_=>'=f'+f
Called with f(), outputs
=f_=>'=f'+f
f=_=>'=f'+f
console.log(f());
Mathematica, 2 bytes
.0
Output:
0.
A number starting with a decimal point such as .123 is interpreted as 0.123, so .0 is interpreted as 0.0. Since the part of the number after the decimal point is zero, Mathematica does not print it.
Retina, 8 bytes
_
$nn$
Prints
n$_
n$
Both contain one _, two n, two $ and three linefeeds.
Note that a linefeed followed by almost any other character is a trivial solution, but it's questionable whether it's valid, because the second character only encodes itself and the linefeed doesn't really encode either output character.
Explanation
_
Replace the empty input with a _.
$nn$
Match an empty string, which happens both before or after the _ and insert a linefeed ($n), an n, and a $. Since we first inserted that _, this adds each of those characters twice, so the n and $ account for the $n, and we get two of the three linefeeds we need in the output. The third linefeed is printed because Retina prints a trailing linefeed by default.
We could also use n$n$ in this stage, which would then print:
n
$_n
$
Braingolf, 36 32 bytes
"V#!1+!@@R!&@&@;"V#!1+!@@R!&@&@;
Outputs ""V#!1+!@@R!&@&@;V#!1+!@@R!&@&@;, which is the source, but with both " at the start, the ; is required at the end to prevent a trailing newline
Explanation:
"V#!1+!@@R!&@&@;"V#!1+!@@R!&@&@;
"V#!1+!@@R!&@&@;" Pushes the charcode of each char in the string
V Create stack2 and switch to it
#! Push charcode of !
1+ Increment to charcode of "
!@@ Print twice, popping the 2nd time
R Return to stack1
!&@&@ Print entire stack twice, popping the 2nd time
; Suppress implicit output to prevent trailing newline
Alternatively (not sure this one actually meets the requirement of it being a proper quine):
Braingolf, 2 bytes
1
\n1, outputs 1\n
Explanation:
\n1
\n No-op, does nothing
1 Pushes 1
Implicit output of last item on stack plus trailing newline
JavaScript (ES6), 40 32 bytes
f=($=`($)=>{$=$+"${"``"}$"}`)=>$+$
No messing around with Function.toString either. As a bonus, the code inside the string almost looks legal. Edit: Saved 8 bytes by using + instead of repeat(2).
Fission 2, 9 8 6 bytes
R"'!+O
Explanation
An atom is created at R, which moves right. This atom then comes across a ", which starts printing mode. In printing mode, all characters (until the matching ") are printed. This means it prints '!+OR in this case. Then, all that is left is printing ", which is done by the remaining characters. '! sets the atom's mass to the character code of !, and + increments it to the character code of ". Then, the character code is output by O and the atom is destroyed, ending the program.
(Actually, this is just a rotation of the shortest quine)
Brainfuck, 158 bytes
>>--<<-[[<+>->+>->+++<<<]>-]<<<<<<[--->>.<<]>>++<<<[->>>.<<<]>>-<<<[--->>>.<<<]>>>--<<<<[++>>>>.<<<<]>>>>+++>--.[---<.>]>+.......++.......<<<>>>>>>>>>-----+++
It may not be the shortest version, but at least it works.
Fun fact, the output code can actually be executed (and it does terminate).
Output
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>--------------------------++++++++++++++++++<....................[[[[[[[]]]]]]]
Explanation
>>--<<-[[<+>->+>->+++<<<]>-] Initializes the tape with the
help of a recurrence relation.
<<<<<<[--->>.<<]>>++<<<[->>>
.<<<]>>-<<<[--->>>.<<<]>>>-- Prints the characters using
<<<<[++>>>>.<<<<]>>>>+++>--. classic loops.
[---<.>]>+.......++.......
<<<>>>>>>>>>-----+++ Junk to complete the anagram.
JavaScript (ES6), 15 bytes
f=(s='f=')=>f+s
Outputs:
(s='f=')=>f+sf=
Snippet:
f=(s='f=')=>f+s
console.log(f());
Ohm, 14 bytes
"æ3M.Cæ"æ3M."C
Output:
æ3M.CæC.M3æ"""
Explanation
"æ3M.Cæ"æ3M."C
"æ3M.Cæ" # Pushes "æ3M.Cæ"
æ # Palindrone of that string
3M # 3 times...
." # Push " on the stack
C # Concatenate with the string above
CJam, 6 bytes
"_`"_`
Prints
_`"_`"
Explanation
"_`" e# Push this string.
_ e# Duplicate.
` e# Stringify it, which wraps it in quotes.
e# Implicitly print stack contents.
QBIC, 8 bytes
?A+@?A@+
I just figured out how to do a proper quine in QBIC. Making an anagram out of it is done by simply switching around the characters in the string literal. There are 24 possible anagrams this way.
05AB1E, 10 bytes
'∞∞''∞'JJ∞
Output:
∞∞''JJ''∞∞
Explanation:
Code | Explanation | Stack
-----------+----------------------------+-------------------
'∞ | Push literal '∞'. | ["∞"]
∞ | Mirror. | ["∞∞"]
'' | Push literal "'". | ["∞∞","'"]
∞ | Mirror. | ["∞∞","''"]
'J | Push literal 'J'. | ["∞∞","''","J"]
J | Join it all together. | ["∞∞''J"]
∞ | Mirror. | ["∞∞''JJ''∞∞"]
-----------+----------------------------+-------------------
| Implicit print. | ∞∞''JJ''∞∞
Groovy, 24 20 bytes
{"""{""*""2""}"""*2}
-4 thanks to CalculatorFeline, the whitespace wasn't needed after all!
Output:
{""*""2""}{""*""2""}
Explanation:
Anonymous closure that, when called, returns {""*""2""} two times (concatenated).
str, 10 bytes
`2xr;`2xr;
Try it online! Outputs `2xr;2xr;`
`2xr;`2xr;
.........; preamble
`2xr;` a string containing those character
2x repeat twice
r print the representation of that doubled string
; end preamble (no program)
Python 3, 32 bytes
print("""p"r"i"n"t"2(")*"""*2)
Prints p"r"i"n"t"2(")*p"r"i"n"t"2(")*\n, sorted output: \n""""""""""""(())**22iinnpprrtt
Haskell, 38 39 bytes
main=print$[0,0]>>"main=print$[0,0]>>"
Try it online! Output:
"main=print$[0,0]>>main=print$[0,0]>>"
Edit: +1 byte because I previously forgot about the implicit trailing newline of print.
Alternative: (Same byte count but does not contain ASCII-owl)
main=print$e++e;e="main=print$e++e;e="
Output:
"main=print$e++e;e=main=print$e++e;e="
Befunge, 11 bytes
' 2+">:#,_@
Prints:
+2 '@_,#:>"
Explanation:
' 2+" Put a " on the stack (32 + 2)
" Put the rest of the code on stack (wrap-around string)
>:#,_ Print stack
@ End
><>, 9 8 7 bytes
Golfed 1 byte thanks to @WheatWizard by using ! and incrementing it to get "
Golfed 1 byte thanks to @ConorO'Brien by using # instead of <!
":1->o#
Outputs "#o>-1:.
Explanation
":1->o#" Push this string (note that the IP wraps around)
: Duplicate the top value of the stack (35 from the "#")
1- Subtract one from it to get 34 ('"')
>o# Print every character on the stack until the program cannot pop any more and still tries to pop a value from the stack afterwards
The program exits with an error from not being able to pop a value from an empty stack
CJam, 8 bytes
"2*`"2*`
Explanation
Similar to the Python example in the question
"2*`" e# Push the string "2*`"
2* e# Repeat it twice
` e# Get its string representation (wrap in quotes)
The output is "2*`2*`".
Ruby, 8 bytes
p"p*2"*2
This prints
"p*2p*2"
Explanation
This works similar to the python answer in the question. It will make the string p*2p*2 then using Ruby's p will print the representation of the string.
Bash, 36 bytes
tee f<<<'tee f<<<""cat f'"''"
cat f
This outputs
tee f<<<""cat f''
tee f<<<""cat f''
(and creates the file f as a side effect, but that's allowed per meta.)
Both the program and output have a trailing newline.
Thought process: I figured that the easiest way to output a string two times, aside from assigning it to a variable, was to do
tee f<<<string
cat f
The string needs to be quoted because it will contain spaces and < characters, so then I had
tee f<<<'tee f<<<cat f'
cat f
which almost works, except it doesn't output the quotes. Fortunately, Bash supports string literal concatenation by simply placing them next to each other, so appending "''" to the herestring and inserting "" inside the single quote part yields this solution.
Japt, 10 9 bytes
Found a better way :-)
Q+2ç"Q+2ç
Outputs "Q+2çQ+2ç. Test it online!
Explanation
Q+2ç"Q+2ç // Implicit: Q = quotation mark
"Q+2ç // Take this string. Q+2ç
2ç // Repeat it twice. Q+2çQ+2ç
Q+ // Prepend a quote. "Q+2çQ+2ç
// Implicit: output result of last expression
Could also be Qi2ç"Qi2ç, which prints Qi2çQi2ç". This one is closer to the standard Japt quine:
"iQ ²"iQ ²
But I do not believe there is any easy way to wedge the quotation mark in the middle of the string for a 9-byte quine.
C, 60 bytes
main(s){printf(s="main(s){s=printf(%c%s%1$c,34,s);}",34,s);}
Just the shortest C quine with trivial modifications.
Output:
main(s){s=printf("main(s){s=printf(%c%s%1$c,34,s);}",34,s);}
05AB1E, 13 bytes
"34çJ∞"34çJ∞
Outputs:
34çJ∞""∞Jç43
"34çJ∞" # Push this string | [ 34çJ∞ ]
34ç # Push a quote (") | [ 34çJ∞, " ]
J # Join | [ 34çJ∞" ]
∞ # Mirror | [ 34çJ∞""∞Jç43 ]
# Implicitly output with a newline
Ruby, 20 bytes
$><<%q($><<%q()*2)*2
This outputs
$><<%q()*2$><<%q()*2
Taking advantage of Ruby's %q(...) string syntax, which supports nested parentheses.
Pyth, 2 bytes
)(
Outputs
()
) # Ends statement, does nothing in this program
( # Create an empty tuple
# Implicitly print the empty tuple