g | x | w | all
Bytes Lang Time Link
042smotslang250507T102310Zsmots-18
0027250211T234653Zais523
016Uiua250209T030208Znoodle p
125AutoHotkey v2241215T082354ZXuesong
014Befunge241206T164235ZMalbolge
048Julia 1.0231012T114954ZMarcMush
036PowerShell Core230317T032207ZJulian
006Vyxal D221018T133311Zlyxal
093Windows command prompt210225T083933Zwasif
098Windows 10 .EXE210225T083546Zwasif
021ksh131219T134111Zkenorb
016Keg191108T064426Zlyxal
173MS SQL Server 2017190826T193323ZAndrei O
032JavaScript190227T142451Zkamoroso
012Japt190226T121137ZASCII-on
006Gol><>190226T134803ZKrystosT
01505AB1E181029T135526ZKevin Cr
142Oracle SQL181125T232835ZDr Y Wit
007Pepe181029T132654Zu-ndefin
006Gol><>180406T173240ZBubbler
002Jelly180403T044718Zdylnan
011Microscript150529T124358ZSuperJed
006Fission150529T111257ZMartin E
022beeswax151228T220424ZM L
013Befunge93 FBBI180403T052200Zosuka_
042JavaScript180403T022351ZYair Ran
014Stax180402T181207ZWeijun Z
024J180402T175326ZBolce Bu
102SmileBASIC180401T153109Z12Me21
003Jstx180401T064540ZQuantum6
nanHelp160616T150723ZErik the
038Tcl180329T183558Zsergiol
066Haskell180323T211243Ztotallyh
038Python 2180323T210001Ztotallyh
011Wumpus180211T111021ZMartin E
008><>170504T163419Zuser4180
144Java 8 function180124T092752ZKevin Cr
010CJam170705T073111ZMartin E
012CJam170526T023612ZEsolangi
115C170526T000713ZMD XF
012Apple ][ BASIC170522T172001ZMD XF
010Alice170412T191557ZMartin E
nanBrainFlak170101T194843ZWheat Wi
004Fuzzy Octo Guacamole160626T200345ZBald Ban
025><>160422T160609Zmbomb007
043JavaScript160403T123951Zericw314
nanBash160408T011715ZNoOneIsH
024MSDOS160401T102005ZNeil
088CSS151018T164944ZMama Fun
002Mathematica150722T104257ZJay Bosa
111Matlab150201T151232Zknedlsep
005huh?131218T162401ZProgramF
148C140131T214149ZJosh
056JavaScript131219T154154ZRy-
031UNIX shell140201T185542ZTomas
031Lua131220T065818ZFreesn&#
002TIBASIC140104T014100ZTimtech
178Racket140104T001634ZSylweste
472C++131222T060244Zuser1123
002GolfScript131220T071045ZJustin
nanJavaScript jQuery 119 92 74 70131219T023640ZAJMansfi
059PHP131219T081909ZHamZa
nanRuby131219T195900ZAjedi32
026J131218T165917ZDan Bron
078MATLAB131219T114557ZDennis J
041Python131219T073230Zshane
010Befunge 98131218T195203ZJustin
003Mathematica131219T032228Zalephalp
034Javascript131219T004234Zscrblnrd
062JavaScript131219T002400ZDoorknob
012GolfScript131218T231424ZIlmari K
4125PHP131218T200850Znl-x
041Perl131218T184743Zsmcg
007BASIC131218T204650Zr3mainer
049Perl131218T194533Zbreadbox
060Ruby131218T174000Zhistocra
013H9+131218T160716ZProgramF

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

Try it online!

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.

Befunge, 14 bytes

">:#,_66*2-,@ 

There are a space at end of code.

Try It Online!

Julia 1.0, 48 bytes

(a=:(print(reverse("(a=:($(a)))|>eval"))))|>eval

Try it online!

based on this quine

Julia 1.0, 52 bytes

"]esrever∘wohs,tnirp[>|.".|>[print,show∘reverse]

Try it online!

based on this quine

PowerShell Core, 36 bytes

&($f={&{-join"&(`$f={$f})"[35..0]}})

Try it online!

Vyxal D, 6 bytes

`IṘ`IṘ

Try it Online!

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.'

enter image description here

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

enter image description here

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:


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

Try it online!

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

Try it online!

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

Try it online!

05AB1E, 15 bytes

0"D34çýR"D34çýR

Try it online.

Or 17 bytes if a default trailing newline isn't allowed:

0"D34çýR?"D34çýR?

Try it online.

Modification of the default 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

Try it online!

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-

Try it online!

Short but boring.

1 gets ignored when - makes -1 the argument which gets printed.

Jelly, 8 bytes

“ṚṾȮ”ȮṾṚ

Try it online!

(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*,@

Try it online!

Relies on nonstandard interpreter behavior. Works pretty much the same as this answer, except it's reversed.

JavaScript, 42 bytes

(f=([a,...b]=`(f=${f})()`)=>a?f(b)+a:'')()

Try it online!

Stax, 14 bytes

"r34b4l"r34b4l

Run and debug it

Yet another adaption of the "34bL"34bL quine.

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

Jstx, 3 bytes

£↕o

Try it online!

Help, WarDoq!, 2 bytes + 25 = 27

 q

The space is needed.

  • Minimum code length is two characters.

Tcl, 38 bytes

puts [string rev [read [open $argv0]]]

Try it online!

Haskell, 66 bytes

main=putStr$reverse$s++show s;s="main=putStr$reverse$s++show s;s="

Try it online!

Python 2, 38 bytes


s="print's cexe;%r=s'%s[::-1]";exec s

Try it online!

Wumpus, 11 bytes

"@o&l]=43#"

Try it online!

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<

Try it online!

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();}

Try it online.

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());}}

Try it online.

Explanation:

And then new StringBuffer(...).reverse() is used to reverse this source code.

CJam, 10 bytes

"W%_`"W%_`

Try it online!

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.

applejs

Commodore 64 BASIC, 13 bytes

RORRE  XATNYS?

c64js

Alice, 10 bytes

"9&o57*to@

Try it online!

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

(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()())(())(()()()()())(()()()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(())(())(())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()())(()()()())(()())(()())(())(()())(()())(()())(()()()())(()())(()()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(())(())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()())(()()()()()()())(()()()()()()()())(()())(()()()())(()())(()()()()()()())(())(()()())(()()()()()()())(()()()()()()()())(())(()()()()()()())(()()()()()()()())(())(()())(())(()())(()())(()()()())(()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()()())(()()()()()()())(()()()()()()()())(())(()()()()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()())(()()()())(()())(()()()())(()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()()())(())(())(())(()()()()()()())(()()()()()()()())(()()()()())(())(()())(()()()()()())(()())(())(()())(()())(()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()())(()()()())(()()()())(()())(()()()()()()()())(()()()()()()())(()()()()()()()())(()()()()()()())(())(()()()()()()())(()()()()()()()())(()()())(()()()())(()())(()()())(()()()())(()()()()()()()())(()()())(()()()()){({}<>)<>}<>([]){({}[()]<(({}[()]<((((((((()()()()()){}){}){})<>))()))>)<>){({}[()]<({}())>){({}[()]<({}(((()()())){}{}){}())>){({}[()]<({}()())>){({}[()]<({}(((()()()){}()){}){}())>){({}[()]<({}()())>){({}[()]<({}(((()()()()())){}{}){})>){(<{}({}()())>)}}}}}}}{}([]<({}<{({}<>)<>}<>>)>){({}[()]<({}<>)<>>)}{}{({}[()]<((({}[()])()))>)}{}<>>)}{}{({}<>)<>}<>

Try it online

+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:

Code difference

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.

PHP, 59

34 + 25 for reading own sourcecode.

<?=strrev(join(file((__FILE__))));

Online demo

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!