| Bytes | Lang | Time | Link |
|---|---|---|---|
| 042 | smotslang | 250507T102310Z | smots-18 |
| 002 | 7 | 250211T234653Z | ais523 |
| 016 | Uiua | 250209T030208Z | noodle p |
| 125 | AutoHotkey v2 | 241215T082354Z | Xuesong |
| 014 | Befunge | 241206T164235Z | Malbolge |
| 048 | Julia 1.0 | 231012T114954Z | MarcMush |
| 036 | PowerShell Core | 230317T032207Z | Julian |
| 006 | Vyxal D | 221018T133311Z | lyxal |
| 093 | Windows command prompt | 210225T083933Z | wasif |
| 098 | Windows 10 .EXE | 210225T083546Z | wasif |
| 021 | ksh | 131219T134111Z | kenorb |
| 016 | Keg | 191108T064426Z | lyxal |
| 173 | MS SQL Server 2017 | 190826T193323Z | Andrei O |
| 032 | JavaScript | 190227T142451Z | kamoroso |
| 012 | Japt | 190226T121137Z | ASCII-on |
| 006 | Gol><> | 190226T134803Z | KrystosT |
| 015 | 05AB1E | 181029T135526Z | Kevin Cr |
| 142 | Oracle SQL | 181125T232835Z | Dr Y Wit |
| 007 | Pepe | 181029T132654Z | u-ndefin |
| 006 | Gol><> | 180406T173240Z | Bubbler |
| 002 | Jelly | 180403T044718Z | dylnan |
| 011 | Microscript | 150529T124358Z | SuperJed |
| 006 | Fission | 150529T111257Z | Martin E |
| 022 | beeswax | 151228T220424Z | M L |
| 013 | Befunge93 FBBI | 180403T052200Z | osuka_ |
| 042 | JavaScript | 180403T022351Z | Yair Ran |
| 014 | Stax | 180402T181207Z | Weijun Z |
| 024 | J | 180402T175326Z | Bolce Bu |
| 102 | SmileBASIC | 180401T153109Z | 12Me21 |
| 003 | Jstx | 180401T064540Z | Quantum6 |
| nan | Help | 160616T150723Z | Erik the |
| 038 | Tcl | 180329T183558Z | sergiol |
| 066 | Haskell | 180323T211243Z | totallyh |
| 038 | Python 2 | 180323T210001Z | totallyh |
| 011 | Wumpus | 180211T111021Z | Martin E |
| 008 | ><> | 170504T163419Z | user4180 |
| 144 | Java 8 function | 180124T092752Z | Kevin Cr |
| 010 | CJam | 170705T073111Z | Martin E |
| 012 | CJam | 170526T023612Z | Esolangi |
| 115 | C | 170526T000713Z | MD XF |
| 012 | Apple ][ BASIC | 170522T172001Z | MD XF |
| 010 | Alice | 170412T191557Z | Martin E |
| nan | BrainFlak | 170101T194843Z | Wheat Wi |
| 004 | Fuzzy Octo Guacamole | 160626T200345Z | Bald Ban |
| 025 | ><> | 160422T160609Z | mbomb007 |
| 043 | JavaScript | 160403T123951Z | ericw314 |
| nan | Bash | 160408T011715Z | NoOneIsH |
| 024 | MSDOS | 160401T102005Z | Neil |
| 088 | CSS | 151018T164944Z | Mama Fun |
| 002 | Mathematica | 150722T104257Z | Jay Bosa |
| 111 | Matlab | 150201T151232Z | knedlsep |
| 005 | huh? | 131218T162401Z | ProgramF |
| 148 | C | 140131T214149Z | Josh |
| 056 | JavaScript | 131219T154154Z | Ry- |
| 031 | UNIX shell | 140201T185542Z | Tomas |
| 031 | Lua | 131220T065818Z | Freesn |
| 002 | TIBASIC | 140104T014100Z | Timtech |
| 178 | Racket | 140104T001634Z | Sylweste |
| 472 | C++ | 131222T060244Z | user1123 |
| 002 | GolfScript | 131220T071045Z | Justin |
| nan | JavaScript jQuery 119 92 74 70 | 131219T023640Z | AJMansfi |
| 059 | PHP | 131219T081909Z | HamZa |
| nan | Ruby | 131219T195900Z | Ajedi32 |
| 026 | J | 131218T165917Z | Dan Bron |
| 078 | MATLAB | 131219T114557Z | Dennis J |
| 041 | Python | 131219T073230Z | shane |
| 010 | Befunge 98 | 131218T195203Z | Justin |
| 003 | Mathematica | 131219T032228Z | alephalp |
| 034 | Javascript | 131219T004234Z | scrblnrd |
| 062 | JavaScript | 131219T002400Z | Doorknob |
| 012 | GolfScript | 131218T231424Z | Ilmari K |
| 4125 | PHP | 131218T200850Z | nl-x |
| 041 | Perl | 131218T184743Z | smcg |
| 007 | BASIC | 131218T204650Z | r3mainer |
| 049 | Perl | 131218T194533Z | breadbox |
| 060 | Ruby | 131218T174000Z | histocra |
| 013 | H9+ | 131218T160716Z | ProgramF |
smotslang, 42 bytes
Obvious error quine for now,
!0 xedni ta "0!" nekot dezingocernU :RORRE
Errors with ERROR: Unrecognized token "!0" at index 0!
This answer is #4 (#3 doesn't exist yet) of my smotslang challenge sweep
7, 2 bytes, 5 characters
37232
Explanation
(As usual when talking about 7, I'm using bold for live commands and non-bold for literals. The only commands that can actually appear in I/O are the live commands 67 and the literals 012345; although it's a useful tool for talking about the language, the boldness is implied when performing I/O, and is neither an explicit input to the program nor part of the output.)
7 is a stack-based language, and the program specifies the initial state of the stack; in this case, it specifies two stack elements, 3 and 232 (with the 7 in the program acting as a separator between them). The topmost element is at the end of the program.
The 7 interpreter's main loop consists of repeatedly running the top stack element, without popping it from the stack. So on the first iteration, the snippet 232 is running. 2 duplicates the top stack element; and 3 pops two stack elements, outputting the element that was on top (the element beneath is discarded). Thus, 232 duplicates the 232 that's on top of the stack, outputs it (discarding both copies), and duplicaes the 3 that's now on top of the stack, outputting 232.
On the second iteration of the main loop, the stack consists of two copies of 3, and thus the snippet 3 is running. This pops both copies, outputting one of them, and then the snippet has finished and the stack is empty (and thus the program terminates).
The program has therefore output 232 and 3. When outputting live code (rather than a literal), the 7 interpreter constructs a literal that would produce the code it's outputting, and outputs that instead – in this case, the output is therefore 7232 and 73, i.e. 723273. But the first digit to be output specifies the output format – in this case, 7 means "output in the same format that the source code was provided in" – so the initial 7 gets interpreted as an output format; the output of the program is therefore 723273 without the first digit, or 23273, which happens to be the source code of the program backwards.
It's interesting that this is effectively the same program as the standard 7 proper quine, 23723, but split up differently between the stack elements. Both programs are formed of two stack elements that each print the other, but this one splits the commands up differently between them, and ends up printing itself backwards rather than forwards as a consequence.
Uiua, 16 bytes
"p&⟜⇌s&"
&s⇌⟜&p
Another fun one (22 bytes):
&pf⊂repr⊸⇌"⇌⊸rper⊂fp&"
AutoHotkey (v2), 125 bytes
MsgBox Format(SubStr(s:="MsgBox Format(SubStr(s:=}c:1{}{}c:{,45),34,s)s,43,)54,{:c}{}{1:c}=:s(rtSbuS(tamroF xoBgsM",45),34,s)
Output
)s,43,)54,"MsgBox Format(SubStr(s:=}c:1{}{}c:{,45),34,s)s,43,)54,{:c}{}{1:c}=:s(rtSbuS(tamroF xoBgsM"=:s(rtSbuS(tamroF xoBgsM
The string s itself is a palindrome. Hard coded to SubStr from 45th character, which is the beginning of the reverse string. Then Format will insert s back to the position.
Julia 1.0, 48 bytes
(a=:(print(reverse("(a=:($(a)))|>eval"))))|>eval
based on this quine
Julia 1.0, 52 bytes
"]esrever∘wohs,tnirp[>|.".|>[print,show∘reverse]
based on this quine
Vyxal D, 6 bytes
`IṘ`IṘ
Explained
`IṘ`IṘ
`IṘ` # The string "IṘ"
I # appended to a backtick-surrounded version of itself
Ṙ # Reversed
Windows command prompt, 93 bytes
.elif hctab ro margorp elbarepo ,dnammoc lanretxe ro lanretni na sa dezingocer ton si 'file.'
Windows 10 .EXE, 98 bytes
.rehsilbup erawtfos eht htiw kcehc ,CP ruoy htiw noisrev a dnif oT
.CP ruoy no nur t'nac ppa sihT
ksh (21 chars)
$ dnuof ton :found :hsk
ksh: dnuof: not found
bash (31 chars)
$ dnuof ton dnammoc :found :hsab-
-bash: dnuof: command not found
sh (29 chars)
$ dnuof ton dnammoc :found :hs-
sh: dnuof: command not found
This one could not work on some Linux distributions, but works on OSX.
tcsh (26 chars)
$ .dnuof ton dnammoC :found.
.dnuof: Command not found.
csh (26 chars)
% .dnuof ton dnammoC :found.
.dnuof: Command not found.
Above should work on all *unix based OS.
Assumptions:
- You don't have
dnuofcommand or alias present.
bash (2-4 chars)
This one most likely doesn't qualify, but I'll share it as curiosity.
Assuming the previous shell command in Bash was $!. The following command:
!$
will produce: $!.
Keg, 16 bytes (SBCS)
`÷^℠⅀:,.`÷^℠⅀:,.
Outputs:
.,:⅀℠^÷`.,:⅀℠^÷`
Explained
`÷^℠⅀:,.`÷^℠⅀:,.
`÷^℠⅀:,.` #Push the string '÷^℠⅀:,.'
÷^ #Item split string and reverse stack
℠⅀ #Summate it all into a string
:,. #Standard Keg quine procedure
MS SQL Server 2017, 173 bytes
declare @ char=1
select
reverse(substring(left(@+replicate('+char(39),3),201),28,174))
declare @ char=1
select
reverse(substring(left(@+replicate('+char(39),3),201),28,174))
Output:
))471,82,)102,)3,)93(rahc+'(etacilper+@(tfel(gnirtsbus(esrever
tceles
1=rahc @ eralced
))471,82,)102,)3,)93(rahc+'(etacilper+@(tfel(gnirtsbus(esrever
tceles
1=rahc @ eralced
Try it on db<>fiddle!
JavaScript, 33 32 bytes
f=([c,...s]='f='+f)=>c?f(s)+c:''
Recursively reverses the string by first providing the quine as the default argument. This beats the syntax error version, which isn't even consistent between browsers.
Japt, 12 bytes
"iQ ²w"iQ ²w
Based off the standard Japt quine
Explanation
"iQ ²w" // Take this string. iQ ²w
iQ // Insert a quote. "iQ ²w
² // Double. "iQ ²w"iQ ²w
w // Reverse. w² Qi"w² Qi"
// Implicitly output.
Gol><>, 6 bytes
sP#Hr"
This is just another way of doing a reverse quine, similar to Bubbler's answer
05AB1E, 15 bytes
0"D34çýR"D34çýR
Or 17 bytes if a default trailing newline isn't allowed:
0"D34çýR?"D34çýR?
Modification of the default quine 0"D34çý"D34çý by adding R.
Explanation:
0 # Push 0 to the stack
# STACK: [0]
"D34çýR" # Push the string 'D34çýR' to the stack
# STACK: [0, 'D34çýR']
D # Duplicate this string
# STACK: [0, 'D34çýR', 'D34çýR']
34ç # Push '"' to the stack
# STACK: [0, 'D34çýR', 'D34çýR', '"']
ý # Join the stack by this '"' delimiter
# STACK: ['0"D34çýR"D34çýR']
R # Reverse the top value on the stack:
# STACK ['Rýç43D"Rýç43D"0']
# (Output the top of the stack implicitly)
Oracle SQL, 142 bytes
select
reverse(replace('@''[@'||chr(93)||'''))from dual;','@',q'[select
reverse(replace('@''[@'||chr(93)||'''))from dual;','@',q]'))from dual;
Oracle SQL, 118 bytes
select
reverse(substr(rpad(1,144,'||chr(39)),27))from dual;select
reverse(substr(rpad(1,144,'||chr(39)),27))from dual;
Test in SQL Plus
SQL> set lines 80 pages 0
SQL> select
2 reverse(replace('@''[@'||chr(93)||'''))from dual;','@',q'[select
3 reverse(replace('@''[@'||chr(93)||'''))from dual;','@',q]'))from dual;
;laud morf))']q,'@',';laud morf))'''||)39(rhc||'@[''@'(ecalper(esrever
tceles['q,'@',';laud morf))'''||)39(rhc||'@[''@'(ecalper(esrever
tceles
SQL> select
2 reverse(substr(rpad(1,144,'||chr(39)),27))from dual;select
3 reverse(substr(rpad(1,144,'||chr(39)),27))from dual;
;laud morf))72,))93(rhc||',441,1(dapr(rtsbus(esrever
tceles;laud morf))72,))93(rhc||',441,1(dapr(rtsbus(esrever
tceles
Pepe, 7 bytes
!RORRER
Link to interpreter (paste the code above, link removes the ! and O)
Explanation:
The interpreter ignores characters other than R,r,E,e so the code is:
RRRER
Now to put the code in explanation:
RE # Push 0
RR # (RR flag: doesn't exist)
R # R doesn't exist, so output RERROR!
Gol><>, 6 bytes
"2ss}H
Same as regular Gol><> quine, except that we just put the 34 at the bottom of the stack, instead of flipping the entire stack.
Jelly, 2 bytes
1-
Short but boring.
1 gets ignored when - makes -1 the argument which gets printed.
Jelly, 8 bytes
“ṚṾȮ”ȮṾṚ
(More) interesting but long.
“ṚṾȮ” is a string literal for ṚṾȮ. Ȯ prints the string and returns it. Ṿ unevals the string, yielding the string “ṚṾȮ” (with the quote characters “” as part of the string). Ṛ reverses this string and its result, ”ȮṾṚ“ implicitly gets printed.
Microscript, 11 bytes
I kind of had to do this.
0"Caxq"Caxq
Surprisingly, this is actually shorter than the language's shortest known true quine. q and a are otherwise equivalent, except q adds wrapping quotes while a does not.
Fission, 6 bytes
A rare case of a generalised quine that is the same length as the normal quine:
"LO+!'
The idea is the same as that of the normal quine, but we're using a left-going atom (starting at the L) so that print mode traverses the code in the opposite order.
beeswax,22 bytes
This is a variant of my beeswax quine (golf you a quine for great good!), also using beeswax’ ability to modify its own code.
J~@D@~1~M.8~3@.+~++~4*
GitHub repository to my beeswax interpreter written in Julia.
Befunge-93 (FBBI), 13 bytes
">:#,_98+2*,@
Relies on nonstandard interpreter behavior. Works pretty much the same as this answer, except it's reversed.
J, 24 Bytes
(|.@,quote)'(|.@,quote)'
Evaluates to the string ')etouq,@.|(')etouq,@.|(
Try it online! Uses echo in order to print result.
Alternatively, if a full program is required:
(echo@|.@,quote)'(echo@|.@,quote)'
Is 34 bytes and prints ')etouq,@.|@ohce(')etouq,@.|@ohce(
Explanation:
Both of these work in the same way:
(|.@,quote)'(|.@,quote)' | Expression to be evaluated
'(|.@,quote)' | String literal containing the code
( ) | Hook, (f g) y is evaluated as y f (g y)
quote | Wrap the string in quotes
, | Append to the unquoted version
|.@ | Reverse the whole thing
SmileBASIC, 118 102 bytes
FOR I=-101TO.?MID$(("+CHR$(34))*3,30,102)[-I];:NEXTFOR I=-100TO.?MID$(("+CHR$(34))*3,30,102)[-I];:NEXT
Wumpus, 11 bytes
"@o&l]=43#"
Explanation
In Wumpus, the IP gets reflected off the boundaries of the grid, so without any further control flow redirection, a program on a single line will bounce back and forth through the code.
"@o&l]=43#" Push the individual code points of this string to the stack.
This gives us the entire code except the quotes.
The IP then bounces off the end and starts moving back through
the code. Since the " ended string mode, this time around the
code will actually be executed.
#34 Push 34, the code point of double quotes.
= Duplicate.
] Shift one copy to the bottom of the stack.
l Push the stack depth (i.e. the program length 11).
&o Print that many characters.
@ Terminate the program.
><>, 10 8 bytes
2 bytes saved thanks to @JoKing by using ' strings instead of " strings
'd3*}>o<
Explanation
'd3*}>o< Push the code points of every character in the string 'd3*}>o<'
d3* Computes 39, the code point of ' (13*3)
Now the stack contains the quote on top of the stack
} Shift the stack to the right, so that the ' will be shifted to the bottom of the stack
This is required because the ' needs to be printed last
>o< Print everything in the stack until the stack is empty
And finally the program ends in an error
Java 8 (function), 144 bytes
v->{String s="v->{String s=%c%s%1$c;return new StringBuffer(s.format(s,34,s)).reverse();}";return new StringBuffer(s.format(s,34,s)).reverse();}
Java 8 (full program), 240 bytes
interface M{static void main(String[]a){String s="interface M{static void main(String[]a){String s=%c%s%1$c;System.out.print(new StringBuffer(s.format(s,34,s)).reverse());}}";System.out.print(new StringBuffer(s.format(s,34,s)).reverse());}}
Explanation:
- The
String scontains the unformatted source code. %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.
And then new StringBuffer(...).reverse() is used to reverse this source code.
CJam, 10 bytes
"W%_`"W%_`
Alternatively:
"`W%_"_W%`
Explanation
"W%_`" e# Push this string which contains the code after the string.
W% e# Reverse the string.
_ e# Duplicate it.
` e# Stringify the copy which wraps it in quotes. The unquoted and
e# quoted versions are then implicitly printed to STDOUT back to back.
In the alternative solution, the string itself already contains the code in reverse and then we only reverse the copy (i.e. the string representation). It's kinda neat that it's then just one character off from being a palindrome.
CJam, 12 bytes
{"~_"\`W%}_~
Explanation:
{ e# Push this block literal:
"~_" e# Push the string "~_"
\ e# Swap
` e# Escape
W% e# Reverse
} e# End
_ e# Duplicate
~ e# Execute
C, 115 bytes
f(){char*s="f(){char*s=c%s%c%;printf(s+42,34,a,34);};)43,s,43,24+s(ftnirp;%c%s%c=s*rahc{)(f";printf(s+42,34,s,34);}
Haha, this is possible in C! Took me a few hours and nearly cheats, but it gets the job done.
Apple ][ BASIC, 12 bytes
RORRE XATNYS?
Hit the soft RESET key on the emulator to enter BASIC mode.
Commodore 64 BASIC, 13 bytes
RORRE XATNYS?
Alice, 10 bytes
"9&o57*to@
Explanation
"9&o57*to@" Push code points of the entire program except the " to the stack.
9& Execute the next command 9 times.
o Print 9 characters from top to bottom (i.e. in reverse order).
57* Compute 5*7 = 35.
t Decrement to 34 (the code point of ").
o Print the quote.
@ Terminate the program.
I'm not 100% sure whether this is optimal. 4 bytes to compute 34 seems painful and while I've found a whole bunch of 4-byte alternatives, I haven't found anything in 3 bytes yet. Some of those alternatives (some of these give other results, but they're 34 (mod 256)):
aN4Y
7aRY
5R1Y
4Pa+
7PYN
Brain-Flak, 3836 + 3 = 3839
(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()())(())(()()()()())(()()()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(())(())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()())(()()()())(()())(()())(())(()())(()())(()())(()()()())(()())(()()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()()())(()())(()()()()()()())(())(()()())(()()()()()()())(()()()()()()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(())(()()()()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()())(()()()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()())(())(()())(()())(()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()())(()()()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()()){({}<>)<>}<>([]){({}[()]<(({}[()]<((((((((()()()()()){}){}){})<>))()))>)<>){({}[()]<({}())>){({}[()]<({}(((()()())){}{}){}())>){({}[()]<({}()())>){({}[()]<({}(((()()()){}()){}){}())>){({}[()]<({}()())>){({}[()]<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}{}([]<({}<{({}<>)<>}<>>)>){({}[()]<({}<>)<>>)}{}{({}[()]<((({}[()])()))>)}{}<>>)}{}{({}<>)<>}<>
+3 bytes from the -A flag
This is a very simple variation on the standard Brain-Flak Quine. In fact this variant is obtained by removing bytes from the original Quine. Here is a picture of the original Quine with the removed characters in red:
The reason this variation is so simple is that the original Quine builds two parts of the program each on its own stack. One of the two parts is reversed so that when they are joined it becomes un-reversed.
So to make the reverse Quine we simply remove a stack swap.
We also have to remove the part of the program that encodes these two bytes otherwise they will be printed as well.
Fuzzy Octo Guacamole, 4 bytes
KNU_
K prints _UNK, N pushes None, and U pushes 0. And _ pops the top value on the stack (but doesn't print). So only _UNK is printed.
><>, 25 bytes
I was surprised to find this hadn't been done yet. :)
...yhsif sllems gnihtemoS
Paste code here and run it.
. is the Jump command, popping x and y off the stack, and moving the IP to (x, y) in the code box. In this case, the stack is empty, so the language's only error message is printed:
Something smells fishy...
JavaScript, 53 50 46 43 bytes
q=_=>("q="+q+";q()").split("").reverse().join("");q()
(q=_=>`(q=${q})()`.split("").reverse().join(""))()
(q=_=>`(q=${q})()`.split``.reverse().join``)()
(q=_=>[...`(q=${q})()`].reverse().join``)()
Please help me shorten this up.
Bash, 8 + 25 for reading source = 33 bytes
rev "$0"
31 for no space in path to file
rev $0
MS-DOS, 24 bytes
eman elif ro dnammoc daB
Output:
Bad command or file name
CSS, 88 bytes
<style>:before,*{display:block;unicode-bidi:bidi-override;direction:rtl;content:'<style>
Put in a blank html page to avoid conflict with other tags.
Mathematica, 2 bytes
1#
Outputs:
#1
Matlab, 111
function d=g();d='gvodujpo!e>h)*<e>(<e>gmjqms)\e)2;29*.2-e-e)29;foe*.2^*<';d=fliplr([d(1:18)-1,d,d(18:end)-1]);
huh?, 5 characters
!hcuO
I actually have NO idea how it works, but If you download the interpreter, and if you write !hcuO, then you get Ouch!
To run this, you need to execute the program like this:
huh.exe !hcuO
It will actually look for a file called !hcuO, but it doesn't exist, so it outputs Ouch!
C, 148
char *a="};)43,b,43,a(ftnirp;]i-57[a=]i[b)++i;67<i;(rof{)(niam;i,]99[b,%c%s%c=a* rahc",b[99],i;main(){for(;i<76;i++)b[i]=a[75-i];printf(a,34,b,34);}
Just a fun play on a typical C quine.
JavaScript, 56
($=_=>_!=$._?_?$(_.slice(1))+_[0]:')':$('($='+$+')('))()
UNIX shell, 31
Real solution at 52 characters:
A='printf "A$ lave;\047`echo $A|rev`\047=A"';eval $A
But beware! Honesty doesn't pay off in today's world! Penalty is too low!!
6 chars + 25 = 31:
rev $0
Lua, 31 Characters
'''' raen rorre xatnys :1:tupni
TI-BASIC, 2
i2
Where i is the imaginary number.
Outputs 2i
Racket 178
(let((l(list->string(reverse(string->list"(let((l(list->string(reverse(string->lista~a~a~))))(q (integer->char 34)))(printf l q l q))"))))(q (integer->char 34)))(printf l q l q))
Output:
))q l q l ftnirp()))43 rahc>-regetni( q())))"))q l q l ftnirp()))43 rahc>-regetni( q())))~a~a~atsil>-gnirts(esrever(gnirts>-tsil(l((tel("tsil>-gnirts(esrever(gnirts>-tsil(l((tel(
Using the powerful printf makes it almost cheating (though I see people pulling their own sources for only 25 penalty.)
C++ 472 characters
A lot of characters but I cant think of a simpler way in a c-based language.
#include<iostream>
#include<string.h>
#define p(t) std::cout<<'}'<<';'<<')'<<strrev(&std::string(#t)[0])<<t;
char* strrev(char*p){char*t=p;char*q=p;while(q&&*q)++q;for(--q;p<q;++p,--q)*p=*p^*q,*q=*p^*q,*p=*p^*q;return t;}
int main(){p("(p{)(niam tni};t nruter;q*^p*=p*,q*^p*=q*,q*^p*=p*)q--,p++;q<p;q--(rof;q++)q*&&q(elihw;p=q*rahc;p=t*rahc{)p*rahc(verrts *rahc;t<<)]0[)t#(gnirts::dts&(verrts<<')'<<';'<<'}'<<tuoc::dts )t(p enifed#>h.gnirts<edulcni#>maertsoi<edulcni#");}
GolfScript - 2
1
(ie \n1 where \n is the newline character)
Output:
1
(ie 1\n)
To quote Ilmari:
GolfScript automatically appends a newline to the end of the output
Thus a newline followed by a number will print the number followed by a newline.
JavaScript jQuery 119 92 74 70 characters
alert($("#answer-16051 pre code").text().split("").reverse().join(""))
Now using jQuery, as minitech suggested in the comments, and manually wrapping with <pre><code> so I can use text() without fear of other code blocks in this post interfering. Manually wrapping with <h4> was incompatible with chromeium when I tested it, so now it should work in most browsers.
This program, if run from this page, finds the code block directly above, reverses its contents, and puts it in an alertbox.
Its easy enough to verify, just paste it into the dev console.
Ruby, 33+25=58
print File.read(__FILE__).reverse
J: 26
Standard quining (26 chars): by defining a function and passing it its own definition, in quotes:
|.(,],2#{:)'|.(,],2#{:)'''
Could probably be made shorter.
J-specific (33 chars): by defining a variable and asking what file the variable was defined in, i.e. this one, then printing out the contents of that file:
1!:2&2|.1!:1(4!:4 a=:<'a'){4!:3''
Must be saved & run from a script (i.e. not in the REPL, because then the answer to the question is "your argument wasn't defined in a file", so there's no file to read).
MATLAB, 78 characters:
|
.snoisserpxe ro stnemetats BALTAM ni dilav ton si retcarahc tupni ehT :rorrE
Note that the solution requires you to begin with a special character (alt+0160) and that it prints exactly the reversed message. (Unlike the python solution)
Python, 43 41
_=']0~::[_%%_ tnirp;%r=_';print _%_[::~0]
Befunge 98 - 10 chars
"8k,'!1+,@
This works if your interpreter does not interpret wrapped lines after " as adding an extra space. If your interpreter does interpret wrapped lines like that, then this 11 char solution works (because duplicate spaces in a string literal are interpreted as one):
"9k,'!1+,@
If I can use g without penalty, then these also work (7 and 8 chars respectively):
"5k,g,@
and
"6k,g,@
Mathematica, 3 chars
a 2
a 2 means a times 2. So the answer is 2 a.
Javascript: 34 characters
reifitnedi detcepxenU :rorrExatnyS
outputs SyntaxError: Unexpected identifier, at least in the Chrome console
JavaScript, 62
function f(){alert((f+'f()').split('').reverse().join(''))}f()
Works for me on latest Chrome (v 31.0.1650.63). Some other browsers may give a different output. (If you reverse that output, then it would work :P)
GolfScript, 12 chars
"-1%.`"-1%.`
This code takes the double-quoted string "-1%.`", reverses it (-1%), duplicates it (.) and un-evals (`) the second copy, restoring the double quotes around it.
Previous entry (13 chars):
{`'.~'+-1%}.~
Based on the 8-char quine {'.~'}.~ from this answer; the extra 5 chars are needed to stringify and reverse the output.
Ps. Note that GolfScript automatically appends a newline to the end of the output. If this is counted as part of the output, a corresponding newline can be prepended to either version of the code without affecting the output, for a cost of one extra char.
PHP, 41 characters (+25)
Don't know if I understood the assignment correctly. But here's a PHP try:
while(!isset($s) || $s) echo isset($s) ? array_pop($s) : ($s = str_split(file_get_contents(__FILE__)) and null);
edit: this can be much shorter:
echo strrev(file_get_contents(__FILE__));
But since it can be that simple, this is probably not what is being asked...
Perl, 41
$_=q{print~~reverse"\$_=q{$_};eval"};eval
Old 52 character answer (27+25 penalty)
open+0;print ~~ reverse <0>
Reads its own source, stores the reverse in a scalar, and prints that.
BASIC, 22 12 7 characters
:-)
1 enil ni rorre xatnyS
EDIT: If you're allowed to enter the program in immediate mode, then this could be reduced to rorre xatnyS (12 characters).
In BBC BASIC, you only need 7 characters:
ekatsiM
Perl, 49 characters
(Note: the actual program is three lines long, the third line being empty.)
print$/,~~reverse<<''x2
print$/,~~reverse<<''x2
Newlines can be a little unintuitive when text is reversed: the output starts with two blank lines. A naive user might expect the output to look more like this program, which is actually significantly shorter:
say~~reverse<< x2
say~~reverse<< x2
But only first listing is actually correct.
Ruby, 60
puts(2,s=<<2.chop.reverse,s)
puts(2,s=<<2.chop.reverse,s)
2
Based on a classic Ruby quine.
H9+, 13 characters
!dlrow ,olleH
As the web page says, all characters that are not H, 9 or + are ignored, so my program will print Hello, world!




