84
\$\begingroup\$

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 character
  • Lowest score wins.

Rules:

  • No using other files (e.g. reverse.txt)
  • Minimum code length is two characters.
  • Your program cannot be a palindrome.
\$\endgroup\$
13
  • 1
    \$\begingroup\$ Looks like this has been done before, just without the "no palindromes" rule. \$\endgroup\$
    – Iszi
    Dec 18 '13 at 18:59
  • 3
    \$\begingroup\$ Are those scores bonuses or penalties? You need to specify in words if something is a penalty or a bonus, because saying +10 can be taken to mean either "score as if it had 10 more characters than it actually does" or "the code can have 10 more characters that won't be scored", or other interpretations. \$\endgroup\$ Dec 18 '13 at 20:24
  • 8
    \$\begingroup\$ @AJMansfield Lowest score wins means that +x would be a penalty, -x would be a bonus. \$\endgroup\$
    – Iszi
    Dec 18 '13 at 20:32
  • 9
    \$\begingroup\$ The one question I have, then, is why is pulling data from the internet given a larger penalty than reading the source file? \$\endgroup\$ Dec 18 '13 at 20:35
  • 4
    \$\begingroup\$ Woohoo, 1st place on the hot network questions list :D Our site needs more attention... \$\endgroup\$
    – Doorknob
    Dec 19 '13 at 0:09

69 Answers 69

1 2
3
0
\$\begingroup\$

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.
\$\endgroup\$
0
\$\begingroup\$

Haskell, 66 bytes

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

Try it online!

\$\endgroup\$
1
0
\$\begingroup\$

Tcl, 38 bytes

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

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Help, WarDoq!, 2 bytes + 25 = 27

 q

The space is needed.

  • Minimum code length is two characters.
\$\endgroup\$
2
  • \$\begingroup\$ Help, WarDoq! was created (years) after this challenge was posted, so you should add a disclaimer stating that it's non-competing. Also, it reads its own source code via the q built-in, so I think this is subject to the +25 bytes penalty. \$\endgroup\$
    – Dennis
    Jun 16 '16 at 15:39
  • \$\begingroup\$ @Dennis I will add them. Thanks for pointing, although there is no other way to make quines here. \$\endgroup\$ Jun 17 '16 at 7:28
0
\$\begingroup\$

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
\$\endgroup\$
0
\$\begingroup\$

Stax, 14 bytes

"r34b4l"r34b4l

Run and debug it

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

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.