I reverse the source code, you negate the input!I double the source, you double the output!I reverse the source code, you negate the output!I transpose the source code, you transpose the input!I reverse the source code, you reverse the input!Source Code MetamorphosisQuine / Reverse QuineDouble-duty quine: quine!dlroW ,olleHSource code GO!I double the source, you double the output!Third time the charmQuine outputs itself in binaryI reverse the source code, you negate the output!I reverse the source code, you reverse the input!I transpose the source code, you transpose the input!

Peaceable Bishops on an 8x8 grid

Can the diameter be controled by the injectivity radius and the volume?

Old short about robots searching for the "Great Enemy" that wiped out mankind

Validity Dates of New Zealand Tourist Visa

Do one quarter of Swedes named 'Ali' have a criminal record?

Why, in the US, are politicians tried by other politicians?

How often are there lunar eclipses on Jupiter

How can I print this equation properly?

Meaning of the term "vertex" in the topic of skeletal formulae

How does "unlimited holidays" work in practice?

Is there no way in Windows 10 to type the Euro symbol € on a US English keyboard that has neither numeric keypad nor "alt gr" key?

What is the difference between "cat < filename" and "cat filename"?

What is the rationale for single engine military aircraft?

How would an Isolationist Country go about opening its borders?

Two windows split horizontally-> can't split vertically

What happens if a crew complies but does not read back ATC instructions?

Tiling on Drywall in Shower

Did the US embassy in Kyiv resist hanging Trump's picture while Yovanovitch was ambassador?

Banking system in C++

How does Wall of Roots interact with +1/+1 counters?

Puzzling is a Forte of Mine

How can I see Explorer.exe's frames per second?

Why aren't flights continued after losing a tire on rotation?

What is the name of ABB*A=BBBB puzzles?



I reverse the source code, you negate the input!


I double the source, you double the output!I reverse the source code, you negate the output!I transpose the source code, you transpose the input!I reverse the source code, you reverse the input!Source Code MetamorphosisQuine / Reverse QuineDouble-duty quine: quine!dlroW ,olleHSource code GO!I double the source, you double the output!Third time the charmQuine outputs itself in binaryI reverse the source code, you negate the output!I reverse the source code, you reverse the input!I transpose the source code, you transpose the input!






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









36















$begingroup$


Blatant rip-off of a rip-off. Go upvote those!



Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated.



Examples



Let's say your source code is ABC and its input is 4. If I write CBA instead and run it, the output must be -4.



Let's say your source code is ABC and its input is -2. If I write CBA instead and run it, the output must be 2.



An input of 0 may give 0 or -0, however, if you do support signed zero, -0 should give 0.










share|improve this question









$endgroup$










  • 5




    $begingroup$
    Why do we need a copy of the same question?
    $endgroup$
    – Christian
    Sep 18 at 7:30






  • 5




    $begingroup$
    @Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
    $endgroup$
    – Adám
    Sep 18 at 7:32






  • 5




    $begingroup$
    A yes, now I see the difference. One needs to read VERY carefully
    $endgroup$
    – Christian
    Sep 18 at 7:34










  • $begingroup$
    If using a structured language like C#, are you just reversing lines?
    $endgroup$
    – PerpetualJ
    Sep 19 at 2:31










  • $begingroup$
    @PerpetualJ No, look at the source like list of characters, some of which are line breaks.
    $endgroup$
    – Adám
    Sep 19 at 5:42

















36















$begingroup$


Blatant rip-off of a rip-off. Go upvote those!



Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated.



Examples



Let's say your source code is ABC and its input is 4. If I write CBA instead and run it, the output must be -4.



Let's say your source code is ABC and its input is -2. If I write CBA instead and run it, the output must be 2.



An input of 0 may give 0 or -0, however, if you do support signed zero, -0 should give 0.










share|improve this question









$endgroup$










  • 5




    $begingroup$
    Why do we need a copy of the same question?
    $endgroup$
    – Christian
    Sep 18 at 7:30






  • 5




    $begingroup$
    @Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
    $endgroup$
    – Adám
    Sep 18 at 7:32






  • 5




    $begingroup$
    A yes, now I see the difference. One needs to read VERY carefully
    $endgroup$
    – Christian
    Sep 18 at 7:34










  • $begingroup$
    If using a structured language like C#, are you just reversing lines?
    $endgroup$
    – PerpetualJ
    Sep 19 at 2:31










  • $begingroup$
    @PerpetualJ No, look at the source like list of characters, some of which are line breaks.
    $endgroup$
    – Adám
    Sep 19 at 5:42













36













36









36


2



$begingroup$


Blatant rip-off of a rip-off. Go upvote those!



Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated.



Examples



Let's say your source code is ABC and its input is 4. If I write CBA instead and run it, the output must be -4.



Let's say your source code is ABC and its input is -2. If I write CBA instead and run it, the output must be 2.



An input of 0 may give 0 or -0, however, if you do support signed zero, -0 should give 0.










share|improve this question









$endgroup$




Blatant rip-off of a rip-off. Go upvote those!



Your task, if you wish to accept it, is to write a program/function that outputs/returns its integer input/argument. The tricky part is that if I reverse your source code, the output must be the original integer negated.



Examples



Let's say your source code is ABC and its input is 4. If I write CBA instead and run it, the output must be -4.



Let's say your source code is ABC and its input is -2. If I write CBA instead and run it, the output must be 2.



An input of 0 may give 0 or -0, however, if you do support signed zero, -0 should give 0.







code-golf math number source-layout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 17 at 19:32









AdámAdám

39.7k2 gold badges89 silver badges230 bronze badges




39.7k2 gold badges89 silver badges230 bronze badges










  • 5




    $begingroup$
    Why do we need a copy of the same question?
    $endgroup$
    – Christian
    Sep 18 at 7:30






  • 5




    $begingroup$
    @Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
    $endgroup$
    – Adám
    Sep 18 at 7:32






  • 5




    $begingroup$
    A yes, now I see the difference. One needs to read VERY carefully
    $endgroup$
    – Christian
    Sep 18 at 7:34










  • $begingroup$
    If using a structured language like C#, are you just reversing lines?
    $endgroup$
    – PerpetualJ
    Sep 19 at 2:31










  • $begingroup$
    @PerpetualJ No, look at the source like list of characters, some of which are line breaks.
    $endgroup$
    – Adám
    Sep 19 at 5:42












  • 5




    $begingroup$
    Why do we need a copy of the same question?
    $endgroup$
    – Christian
    Sep 18 at 7:30






  • 5




    $begingroup$
    @Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
    $endgroup$
    – Adám
    Sep 18 at 7:32






  • 5




    $begingroup$
    A yes, now I see the difference. One needs to read VERY carefully
    $endgroup$
    – Christian
    Sep 18 at 7:34










  • $begingroup$
    If using a structured language like C#, are you just reversing lines?
    $endgroup$
    – PerpetualJ
    Sep 19 at 2:31










  • $begingroup$
    @PerpetualJ No, look at the source like list of characters, some of which are line breaks.
    $endgroup$
    – Adám
    Sep 19 at 5:42







5




5




$begingroup$
Why do we need a copy of the same question?
$endgroup$
– Christian
Sep 18 at 7:30




$begingroup$
Why do we need a copy of the same question?
$endgroup$
– Christian
Sep 18 at 7:30




5




5




$begingroup$
@Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
$endgroup$
– Adám
Sep 18 at 7:32




$begingroup$
@Christian That one outputs a constant number (and its negation) whereas this one has to take input and return/negate it. A very different job in a lot of languages.
$endgroup$
– Adám
Sep 18 at 7:32




5




5




$begingroup$
A yes, now I see the difference. One needs to read VERY carefully
$endgroup$
– Christian
Sep 18 at 7:34




$begingroup$
A yes, now I see the difference. One needs to read VERY carefully
$endgroup$
– Christian
Sep 18 at 7:34












$begingroup$
If using a structured language like C#, are you just reversing lines?
$endgroup$
– PerpetualJ
Sep 19 at 2:31




$begingroup$
If using a structured language like C#, are you just reversing lines?
$endgroup$
– PerpetualJ
Sep 19 at 2:31












$begingroup$
@PerpetualJ No, look at the source like list of characters, some of which are line breaks.
$endgroup$
– Adám
Sep 19 at 5:42




$begingroup$
@PerpetualJ No, look at the source like list of characters, some of which are line breaks.
$endgroup$
– Adám
Sep 19 at 5:42










50 Answers
50






active

oldest

votes













1 2
next












18

















$begingroup$


PowerShell, 18 14 bytes





$args#"sgra$"-


Try it online! !enilno ti yrT



First of the trivial comment-abuse answers






share|improve this answer












$endgroup$










  • 4




    $begingroup$
    Oh, God. Not this again.
    $endgroup$
    – JL2210
    Sep 17 at 19:57






  • 1




    $begingroup$
    "First of the trivial comment-abuse answers" Redeemed by the TIO links!
    $endgroup$
    – Jonah
    Sep 18 at 22:06


















18

















$begingroup$


J, 3 bytes



-&0


Try it online!



-&0 is "argument minus 0"



0&- is "0 minus argument"






share|improve this answer










$endgroup$










  • 3




    $begingroup$
    this is really quite nice :)
    $endgroup$
    – Conor O'Brien
    Sep 18 at 2:59






  • 3




    $begingroup$
    Clever, I didn't think of that one, but rather ][- etc.
    $endgroup$
    – Adám
    Sep 18 at 5:35


















13

















$begingroup$

JavaScript, 11 bytes



n=>n//n->=n


Try it Online! | Reversed






share|improve this answer










$endgroup$






















    11

















    $begingroup$

    x86 machine code, 3 bytes



    C3 D8 F7


    The above bytes of code define a function that is a no-op: it simply returns control to the caller. That function is followed by two garbage bytes that will not be executed, since they come after a return—they are in "no man's land". In assembler mnemonics:



    ret ; C3 
    fdiv st(0), st(7) ; D8 F7


    Okay, so now some troll comes by and reverses the order of the bytes:



    F7 D8 C3


    These bytes now define a function that takes an integer argument in the EAX register, negates it, and returns control to the caller. In assembler mnemonics:



    neg eax ; F7 D8
    ret ; C3


    So…that was simple. :-)



    Note that we can make the "negation" instruction be anything we want, since it is never executed in the "forward" orientation and only executed in the "reversed" orientation. Therefore, we can follow the same pattern to do arbitrarily more complicated stuff. For example, here we take an integer argument in a different register (say, EDI, to follow the System V calling convention commonly used on *nix systems), negate it, and return it in the conventional EAX register:



    C3 ret
    D8 F7 fdiv st(0), st(7) ; garbage bytes that
    F8 clc ; | never get executed,
    89 .byte 0x89 ; / so nobody cares


      ↓ ↓



    89 F8 mov eax, edi
    F7 D8 neg eax
    C3 ret





    share|improve this answer










    $endgroup$






















      10

















      $begingroup$


      Jelly, 2 bytes



      oN


      Try it online! and its reverse.



      oN - (input) OR ((input) negated)

      No - ((input) negated) OR (input)





      share|improve this answer










      $endgroup$














      • $begingroup$
        Heh, you can also do ḷN, no need for the OR logic. :D
        $endgroup$
        – Erik the Outgolfer
        Sep 17 at 21:54







      • 10




        $begingroup$
        Na, words give aN aesthetic effect :)
        $endgroup$
        – Jonathan Allan
        Sep 17 at 22:05


















      7

















      $begingroup$


      Haskell, 8 bytes



      Anonymous identity function, turning into subtraction from 0 when reversed.





      id--)-0(


      Try it online!



      Reversed:



      (0-)--di


      Try it online!






      share|improve this answer










      $endgroup$










      • 2




        $begingroup$
        You’ve managed to break the code highlighting with your reversed version!
        $endgroup$
        – Tim
        Sep 19 at 9:57










      • $begingroup$
        @Tim Curious. Testing suggests it fails when a comment starts right after a right parenthesis.
        $endgroup$
        – Ørjan Johansen
        Sep 20 at 2:07


















      6

















      $begingroup$


      Whitespace, 48 bytes



      S S S N
      S N
      S T N
      T T T T T T N
      S T N
      N
      N
      T S N
      T N
      S S T N
      T T S S T T T T T N
      T S N
      S N
      S S S


      Letters S (space), T (tab), and N (new-line) added as highlighting only.



      Minor modification of my Whitespace answer for the I reverse the source code, you negate the output! challenge.



      Try it online or try it online reversed (with raw spaces, tabs and new-lines only).



      Explanation:





      Utilizing the Exit Program builtin being a short palindrome NNN.

      The regular program will:



      SSSN # Push 0 to the stack
      SNS # Duplicate it
      TNTT # Read STDIN as integer, and store it at heap address 0
      TTT # Retrieve the input from heap address 0, and push it to the stack
      TNST # Pop and print the top of the stack as number
      NNN # Exit the program, making everything after it no-ops


      The reverse program will:



      SSSN # Push 0 to the stack
      SNS # Duplicate it
      TNTT # Read STDIN as integer, and store it at heap address 0
      TTT # Retrieve the input from heap address 0, and push it to the stack
      SSTTN # Push -1 to the stack
      TSSN # Multiply the top two values on the stack together
      TNST # Pop and print the top of the stack as number
      NNN # Exit the program, making everything after it no-ops


      Small additional explanation of pushing a number:



      • First S: Enable Stack Manipulation

      • Second S: Push a number to the stack


      • S or T: Positive/negative respectively

      • Some S/T followed by a trailing N: number in binary, where S=0 and T=1

      I.e. SSTTSTSN pushes -10. For the 0 we don't need an explicit S=0, so simply SSSN or SSTN is enough.






      share|improve this answer










      $endgroup$






















        5

















        $begingroup$


        Perl 6 / Raku, 3 bytes





        *-0


        Try it online!



        Creates a Whatever code block. Read in normally its standard block equivalent is -> x x - 0, but in reverse it becomes -> x 0 - x.






        share|improve this answer










        $endgroup$






















          5

















          $begingroup$


          C (clang), 23 bytes





          f(*x)//};x*-=x*improve this answer










          $endgroup$

















            7















            7











            7







            $begingroup$


            Haskell, 8 bytes



            Anonymous identity function, turning into subtraction from 0 when reversed.





            id--)-0(


            Try it online!



            Reversed:



            (0-)--di


            Try it online!






            share;x*-=x*improve this answer










            $endgroup$



















              $endgroup$



















                $endgroup$




                C (clang), 23 bytes





                f(*x)//;x*-=x*improve this answer




                shareimprove this answer












                $endgroup$














                • $begingroup$
                  Is this undefined behaviour abuse? I don't think Brain-Flak specification allows such parenthesis.
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:06










                • $begingroup$
                  @TwilightSparkle The # starts a comment, so the parenthesis in the original version are ignored.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:08










                • $begingroup$
                  Oh yeah, I forgot! But it only works in Rain-Flak then(It's the official intepreter though). You will probably need to mention it?
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:12










                • $begingroup$
                  @TwilightSparkle added a note for clarification. Thanks.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:21










                • $begingroup$
                  Fun little challenge: Can you do this without comments if you also swap opening/closing brackets instead of just reversing?
                  $endgroup$
                  – DJMcMayhem
                  Sep 18 at 21:42













                5















                5











                5







                $begingroup$


                Brain-Flak, 7 bytes



                #)]improve this answer












                $endgroup$




                Brain-Flak, 7 bytes



                #)]{[(


                Try it online!



                Reversed:



                ([])#


                Try it online!



                Note: Only works in interpreters that support comments (e.g. works in Rain-Flak, but not in BrainHack)




                If we also swap opening/closing brackets instead of just reversing the bytes we can do this in 8 bytes without using comments:



                ([])


                Try it online!
                Try it reversed!







                share|improve this answer















                share|improve this answer




                share|improve this answer








                edited Sep 18 at 21:53

























                answered Sep 17 at 22:18









                RileyRiley

                11.3k1 gold badge16 silver badges48 bronze badges




                11.3k1 gold badge16 silver badges48 bronze badges














                • $begingroup$
                  Is this undefined behaviour abuse? I don't think Brain-Flak specification allows such parenthesis.
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:06










                • $begingroup$
                  @TwilightSparkle The # starts a comment, so the parenthesis in the original version are ignored.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:08










                • $begingroup$
                  Oh yeah, I forgot! But it only works in Rain-Flak then(It's the official intepreter though). You will probably need to mention it?
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:12










                • $begingroup$
                  @TwilightSparkle added a note for clarification. Thanks.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:21










                • $begingroup$
                  Fun little challenge: Can you do this without comments if you also swap opening/closing brackets instead of just reversing?
                  $endgroup$
                  – DJMcMayhem
                  Sep 18 at 21:42
















                • $begingroup$
                  Is this undefined behaviour abuse? I don't think Brain-Flak specification allows such parenthesis.
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:06










                • $begingroup$
                  @TwilightSparkle The # starts a comment, so the parenthesis in the original version are ignored.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:08










                • $begingroup$
                  Oh yeah, I forgot! But it only works in Rain-Flak then(It's the official intepreter though). You will probably need to mention it?
                  $endgroup$
                  – HighlyRadioactive
                  Sep 18 at 14:12










                • $begingroup$
                  @TwilightSparkle added a note for clarification. Thanks.
                  $endgroup$
                  – Riley
                  Sep 18 at 14:21










                • $begingroup$
                  Fun little challenge: Can you do this without comments if you also swap opening/closing brackets instead of just reversing?
                  $endgroup$
                  – DJMcMayhem
                  Sep 18 at 21:42















                $begingroup$
                Is this undefined behaviour abuse? I don't think Brain-Flak specification allows such parenthesis.
                $endgroup$
                – HighlyRadioactive
                Sep 18 at 14:06




                $begingroup$
                Is this undefined behaviour abuse? I don't think Brain-Flak specification allows such parenthesis.
                $endgroup$
                – HighlyRadioactive
                Sep 18 at 14:06












                $begingroup$
                @TwilightSparkle The # starts a comment, so the parenthesis in the original version are ignored.
                $endgroup$
                – Riley
                Sep 18 at 14:08




                $begingroup$
                @TwilightSparkle The # starts a comment, so the parenthesis in the original version are ignored.
                $endgroup$
                – Riley
                Sep 18 at 14:08












                $begingroup$
                Oh yeah, I forgot! But it only works in Rain-Flak then(It's the official intepreter though). You will probably need to mention it?
                $endgroup$
                – HighlyRadioactive
                Sep 18 at 14:12




                $begingroup$
                Oh yeah, I forgot! But it only works in Rain-Flak then(It's the official intepreter though). You will probably need to mention it?
                $endgroup$
                – HighlyRadioactive
                Sep 18 at 14:12












                $begingroup$
                @TwilightSparkle added a note for clarification. Thanks.
                $endgroup$
                – Riley
                Sep 18 at 14:21




                $begingroup$
                @TwilightSparkle added a note for clarification. Thanks.
                $endgroup$
                – Riley
                Sep 18 at 14:21












                $begingroup$
                Fun little challenge: Can you do this without comments if you also swap opening/closing brackets instead of just reversing?
                $endgroup$
                – DJMcMayhem
                Sep 18 at 21:42




                $begingroup$
                Fun little challenge: Can you do this without comments if you also swap opening/closing brackets instead of just reversing?
                $endgroup$
                – DJMcMayhem
                Sep 18 at 21:42











                4

















                $begingroup$


                Labyrinth / Hexagony, 6 bytes



                Labyrinth:



                ?!@!`?


                Try it online! and its reverse.



                Hexagony:



                ?!@!~?


                Try it online! and its reverse.



                How?



                ? - take a signed integer
                (` / ~) - negate
                ! - output top-of-stack / current-memory-edge
                @ - exit





                share|improve this answer












                $endgroup$



















                  4

















                  $begingroup$


                  Labyrinth / Hexagony, 6 bytes



                  Labyrinth:



                  ?!@!`?


                  Try it online! and its reverse.



                  Hexagony:



                  ?!@!~?


                  Try it online! and its reverse.



                  How?



                  ? - take a signed integer
                  (` / ~) - negate
                  ! - output top-of-stack / current-memory-edge
                  @ - exit





                  share|improve this answer












                  $endgroup$

















                    4















                    4











                    4







                    $begingroup$


                    Labyrinth / Hexagony, 6 bytes



                    Labyrinth:



                    ?!@!`?


                    Try it online! and its reverse.



                    Hexagony:



                    ?!@!~?


                    Try it online! and its reverse.



                    How?



                    ? - take a signed integer
                    (` / ~) - negate
                    ! - output top-of-stack / current-memory-edge
                    @ - exit





                    share|improve this answer












                    $endgroup$




                    Labyrinth / Hexagony, 6 bytes



                    Labyrinth:



                    ?!@!`?


                    Try it online! and its reverse.



                    Hexagony:



                    ?!@!~?


                    Try it online! and its reverse.



                    How?



                    ? - take a signed integer
                    (` / ~) - negate
                    ! - output top-of-stack / current-memory-edge
                    @ - exit






                    share|improve this answer















                    share|improve this answer




                    share|improve this answer








                    edited Sep 17 at 21:06

























                    answered Sep 17 at 20:49









                    Jonathan AllanJonathan Allan

                    63.9k5 gold badges46 silver badges191 bronze badges




                    63.9k5 gold badges46 silver badges191 bronze badges
























                        4

















                        $begingroup$


                        Python 3, 22 bytes





                        lambda x:x#x-:x adbmal


                        Try it online!



                        A lambda which implements the identity function (or negation)






                        share|improve this answer










                        $endgroup$



















                          4

















                          $begingroup$


                          Python 3, 22 bytes





                          lambda x:x#x-:x adbmal


                          Try it online!



                          A lambda which implements the identity function (or negation)






                          share|improve this answer










                          $endgroup$

















                            4















                            4











                            4







                            $begingroup$


                            Python 3, 22 bytes





                            lambda x:x#x-:x adbmal


                            Try it online!



                            A lambda which implements the identity function (or negation)






                            share|improve this answer










                            $endgroup$




                            Python 3, 22 bytes





                            lambda x:x#x-:x adbmal


                            Try it online!



                            A lambda which implements the identity function (or negation)







                            share|improve this answer













                            share|improve this answer




                            share|improve this answer










                            answered Sep 18 at 5:13









                            Nick KennedyNick Kennedy

                            8,2061 gold badge9 silver badges22 bronze badges




                            8,2061 gold badge9 silver badges22 bronze badges
























                                4

















                                $begingroup$


                                MarioLANG, 22 bytes



                                ;:
                                =#
                                :)!
                                --
                                <(
                                "
                                [>
                                ;


                                Try it online!



                                He just inputs and outputs the number before he falls to EOF



                                reversed:



                                ;
                                >[
                                "
                                (<
                                --
                                !):
                                #=
                                :;


                                Try it online!



                                He loops until the input value is 0 and the output value is -input, the he says the number.






                                share|improve this answer










                                $endgroup$



















                                  4

















                                  $begingroup$


                                  MarioLANG, 22 bytes



                                  ;:
                                  =#
                                  :)!
                                  --
                                  <(
                                  "
                                  [>
                                  ;


                                  Try it online!



                                  He just inputs and outputs the number before he falls to EOF



                                  reversed:



                                  ;
                                  >[
                                  "
                                  (<
                                  --
                                  !):
                                  #=
                                  :;


                                  Try it online!



                                  He loops until the input value is 0 and the output value is -input, the he says the number.






                                  share|improve this answer










                                  $endgroup$

















                                    4















                                    4











                                    4







                                    $begingroup$


                                    MarioLANG, 22 bytes



                                    ;:
                                    =#
                                    :)!
                                    --
                                    <(
                                    "
                                    [>
                                    ;


                                    Try it online!



                                    He just inputs and outputs the number before he falls to EOF



                                    reversed:



                                    ;
                                    >[
                                    "
                                    (<
                                    --
                                    !):
                                    #=
                                    :;


                                    Try it online!



                                    He loops until the input value is 0 and the output value is -input, the he says the number.






                                    share|improve this answer










                                    $endgroup$




                                    MarioLANG, 22 bytes



                                    ;:
                                    =#
                                    :)!
                                    --
                                    <(
                                    "
                                    [>
                                    ;


                                    Try it online!



                                    He just inputs and outputs the number before he falls to EOF



                                    reversed:



                                    ;
                                    >[
                                    "
                                    (<
                                    --
                                    !):
                                    #=
                                    :;


                                    Try it online!



                                    He loops until the input value is 0 and the output value is -input, the he says the number.







                                    share|improve this answer













                                    share|improve this answer




                                    share|improve this answer










                                    answered Sep 18 at 9:34









                                    DorianDorian

                                    1,4216 silver badges8 bronze badges




                                    1,4216 silver badges8 bronze badges
























                                        4

















                                        $begingroup$


                                        R, 23 bytes





                                        I decided to give it a go without the comment trick.



                                        Forward



                                        `+`=scan;""+-0;nacs=`+`


                                        Try it online!



                                        Reverse



                                        `+`=scan;0-+"";nacs=`+`


                                        Try it online!



                                        In the forward version + is acting a binary operator, and - is a unary operator.



                                        In the reverse the + becomes unary and the - is binary. So scan function takes the arguments: file="" which means stdin and what=0, which are also defaults. So when the + is unary the first argument is on the right, when it is binary the first argument is on the left.



                                        The



                                        ;nacs=`+`


                                        part of the code does nothing really useful, so in a sense my code is not really very much more valid than using the comment trick.






                                        share|improve this answer










                                        $endgroup$










                                        • 1




                                          $begingroup$
                                          This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                          $endgroup$
                                          – Robin Ryder
                                          Sep 19 at 15:45
















                                        4

















                                        $begingroup$


                                        R, 23 bytes





                                        I decided to give it a go without the comment trick.



                                        Forward



                                        `+`=scan;""+-0;nacs=`+`


                                        Try it online!



                                        Reverse



                                        `+`=scan;0-+"";nacs=`+`


                                        Try it online!



                                        In the forward version + is acting a binary operator, and - is a unary operator.



                                        In the reverse the + becomes unary and the - is binary. So scan function takes the arguments: file="" which means stdin and what=0, which are also defaults. So when the + is unary the first argument is on the right, when it is binary the first argument is on the left.



                                        The



                                        ;nacs=`+`


                                        part of the code does nothing really useful, so in a sense my code is not really very much more valid than using the comment trick.






                                        share|improve this answer










                                        $endgroup$










                                        • 1




                                          $begingroup$
                                          This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                          $endgroup$
                                          – Robin Ryder
                                          Sep 19 at 15:45














                                        4















                                        4











                                        4







                                        $begingroup$


                                        R, 23 bytes





                                        I decided to give it a go without the comment trick.



                                        Forward



                                        `+`=scan;""+-0;nacs=`+`


                                        Try it online!



                                        Reverse



                                        `+`=scan;0-+"";nacs=`+`


                                        Try it online!



                                        In the forward version + is acting a binary operator, and - is a unary operator.



                                        In the reverse the + becomes unary and the - is binary. So scan function takes the arguments: file="" which means stdin and what=0, which are also defaults. So when the + is unary the first argument is on the right, when it is binary the first argument is on the left.



                                        The



                                        ;nacs=`+`


                                        part of the code does nothing really useful, so in a sense my code is not really very much more valid than using the comment trick.






                                        share|improve this answer










                                        $endgroup$




                                        R, 23 bytes





                                        I decided to give it a go without the comment trick.



                                        Forward



                                        `+`=scan;""+-0;nacs=`+`


                                        Try it online!



                                        Reverse



                                        `+`=scan;0-+"";nacs=`+`


                                        Try it online!



                                        In the forward version + is acting a binary operator, and - is a unary operator.



                                        In the reverse the + becomes unary and the - is binary. So scan function takes the arguments: file="" which means stdin and what=0, which are also defaults. So when the + is unary the first argument is on the right, when it is binary the first argument is on the left.



                                        The



                                        ;nacs=`+`


                                        part of the code does nothing really useful, so in a sense my code is not really very much more valid than using the comment trick.







                                        share|improve this answer













                                        share|improve this answer




                                        share|improve this answer










                                        answered Sep 18 at 13:04









                                        Aaron HaymanAaron Hayman

                                        4616 bronze badges




                                        4616 bronze badges










                                        • 1




                                          $begingroup$
                                          This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                          $endgroup$
                                          – Robin Ryder
                                          Sep 19 at 15:45













                                        • 1




                                          $begingroup$
                                          This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                          $endgroup$
                                          – Robin Ryder
                                          Sep 19 at 15:45








                                        1




                                        1




                                        $begingroup$
                                        This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                        $endgroup$
                                        – Robin Ryder
                                        Sep 19 at 15:45





                                        $begingroup$
                                        This is very smart (+1). We often redefine the R operators to golf bytes, but I think this is the first time I have seen + redefined to be used as both unary and binary. It took me a minute to understand how this was parsed… No other operator name would have done the job.
                                        $endgroup$
                                        – Robin Ryder
                                        Sep 19 at 15:45












                                        4

















                                        $begingroup$

                                        Haskell, 12 bytes



                                        f=id;x-0=x f


                                        Try it online! Reverse:



                                        f x=0-x;di=f


                                        Try it online!



                                        Not as short as Ørjan Johansen's answer, but without comments.






                                        share|improve this answer










                                        $endgroup$



















                                          4

















                                          $begingroup$

                                          Haskell, 12 bytes



                                          f=id;x-0=x f


                                          Try it online! Reverse:



                                          f x=0-x;di=f


                                          Try it online!



                                          Not as short as Ørjan Johansen's answer, but without comments.






                                          share|improve this answer










                                          $endgroup$

















                                            4















                                            4











                                            4







                                            $begingroup$

                                            Haskell, 12 bytes



                                            f=id;x-0=x f


                                            Try it online! Reverse:



                                            f x=0-x;di=f


                                            Try it online!



                                            Not as short as Ørjan Johansen's answer, but without comments.






                                            share|improve this answer










                                            $endgroup$



                                            Haskell, 12 bytes



                                            f=id;x-0=x f


                                            Try it online! Reverse:



                                            f x=0-x;di=f


                                            Try it online!



                                            Not as short as Ørjan Johansen's answer, but without comments.







                                            share|improve this answer













                                            share|improve this answer




                                            share|improve this answer










                                            answered Sep 18 at 16:17









                                            niminimi

                                            34.5k3 gold badges28 silver badges92 bronze badges




                                            34.5k3 gold badges28 silver badges92 bronze badges
























                                                4

















                                                $begingroup$

                                                Perl 5 (-p), 7 6 bytes



                                                -1 thanks to @primo



                                                $_*=$#


                                                TIO



                                                A comment doesn't change input



                                                #1-=*_$


                                                Negate the input



                                                $_*=-1#


                                                TIO






                                                share|improve this answer












                                                $endgroup$














                                                • $begingroup$
                                                  -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                  $endgroup$
                                                  – primo
                                                  Sep 18 at 16:32







                                                • 1




                                                  $begingroup$
                                                  however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 18 at 18:08










                                                • $begingroup$
                                                  Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                  $endgroup$
                                                  – primo
                                                  Sep 19 at 11:26






                                                • 2




                                                  $begingroup$
                                                  @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                  $endgroup$
                                                  – Dada
                                                  Sep 20 at 15:31










                                                • $begingroup$
                                                  that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 21 at 6:18
















                                                4

















                                                $begingroup$

                                                Perl 5 (-p), 7 6 bytes



                                                -1 thanks to @primo



                                                $_*=$#


                                                TIO



                                                A comment doesn't change input



                                                #1-=*_$


                                                Negate the input



                                                $_*=-1#


                                                TIO






                                                share|improve this answer












                                                $endgroup$














                                                • $begingroup$
                                                  -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                  $endgroup$
                                                  – primo
                                                  Sep 18 at 16:32







                                                • 1




                                                  $begingroup$
                                                  however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 18 at 18:08










                                                • $begingroup$
                                                  Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                  $endgroup$
                                                  – primo
                                                  Sep 19 at 11:26






                                                • 2




                                                  $begingroup$
                                                  @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                  $endgroup$
                                                  – Dada
                                                  Sep 20 at 15:31










                                                • $begingroup$
                                                  that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 21 at 6:18














                                                4















                                                4











                                                4







                                                $begingroup$

                                                Perl 5 (-p), 7 6 bytes



                                                -1 thanks to @primo



                                                $_*=$#


                                                TIO



                                                A comment doesn't change input



                                                #1-=*_$


                                                Negate the input



                                                $_*=-1#


                                                TIO






                                                share|improve this answer












                                                $endgroup$



                                                Perl 5 (-p), 7 6 bytes



                                                -1 thanks to @primo



                                                $_*=$#


                                                TIO



                                                A comment doesn't change input



                                                #1-=*_$


                                                Negate the input



                                                $_*=-1#


                                                TIO







                                                share|improve this answer















                                                share|improve this answer




                                                share|improve this answer








                                                edited Sep 18 at 18:10

























                                                answered Sep 18 at 5:07









                                                Nahuel FouilleulNahuel Fouilleul

                                                5,2671 gold badge5 silver badges15 bronze badges




                                                5,2671 gold badge5 silver badges15 bronze badges














                                                • $begingroup$
                                                  -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                  $endgroup$
                                                  – primo
                                                  Sep 18 at 16:32







                                                • 1




                                                  $begingroup$
                                                  however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 18 at 18:08










                                                • $begingroup$
                                                  Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                  $endgroup$
                                                  – primo
                                                  Sep 19 at 11:26






                                                • 2




                                                  $begingroup$
                                                  @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                  $endgroup$
                                                  – Dada
                                                  Sep 20 at 15:31










                                                • $begingroup$
                                                  that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 21 at 6:18

















                                                • $begingroup$
                                                  -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                  $endgroup$
                                                  – primo
                                                  Sep 18 at 16:32







                                                • 1




                                                  $begingroup$
                                                  however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 18 at 18:08










                                                • $begingroup$
                                                  Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                  $endgroup$
                                                  – primo
                                                  Sep 19 at 11:26






                                                • 2




                                                  $begingroup$
                                                  @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                  $endgroup$
                                                  – Dada
                                                  Sep 20 at 15:31










                                                • $begingroup$
                                                  that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                  $endgroup$
                                                  – Nahuel Fouilleul
                                                  Sep 21 at 6:18
















                                                $begingroup$
                                                -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                $endgroup$
                                                – primo
                                                Sep 18 at 16:32





                                                $begingroup$
                                                -1: $_*=$# TIO. Note that the # must be the very last byte of the program, otherwise it will be interpreted as the variable $#, rather than the last index of the array with name <empty>.
                                                $endgroup$
                                                – primo
                                                Sep 18 at 16:32





                                                1




                                                1




                                                $begingroup$
                                                however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                $endgroup$
                                                – Nahuel Fouilleul
                                                Sep 18 at 18:08




                                                $begingroup$
                                                however i don't understand how it works because trying to print $# gives either an error (if # is not the last character) or nothing
                                                $endgroup$
                                                – Nahuel Fouilleul
                                                Sep 18 at 18:08












                                                $begingroup$
                                                Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                $endgroup$
                                                – primo
                                                Sep 19 at 11:26




                                                $begingroup$
                                                Seems to only work with -p or -n. I suspect the boilerplate has something to do with it...
                                                $endgroup$
                                                – primo
                                                Sep 19 at 11:26




                                                2




                                                2




                                                $begingroup$
                                                @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                $endgroup$
                                                – Dada
                                                Sep 20 at 15:31




                                                $begingroup$
                                                @primo It works because -p/-n adds a ; after the code. Which means that $# is actually $#;: the size of the array @;. If the size of @; changes, the result isn't correct anymore (TIO). Anyway, this is super clever, well done! :)
                                                $endgroup$
                                                – Dada
                                                Sep 20 at 15:31












                                                $begingroup$
                                                that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                $endgroup$
                                                – Nahuel Fouilleul
                                                Sep 21 at 6:18





                                                $begingroup$
                                                that's the explanation could be seen with perl -MO=Deparse -p <(echo -n '$_*=$#'), because it seems perl -MO=Deparse -pe '$_*=$#' adds a newline
                                                $endgroup$
                                                – Nahuel Fouilleul
                                                Sep 21 at 6:18












                                                4

















                                                $begingroup$


                                                Gaia, 2 bytes



                                                _@


                                                Try it online!



                                                _	| implicit push input and negate
                                                @ | push next input OR push last input (when all inputs have been pushed)
                                                | implicit print TOS


                                                Reversed:



                                                @	| push input
                                                _ | negate
                                                | implicit print TOS





                                                share|improve this answer












                                                $endgroup$



















                                                  4

















                                                  $begingroup$


                                                  Gaia, 2 bytes



                                                  _@


                                                  Try it online!



                                                  _	| implicit push input and negate
                                                  @ | push next input OR push last input (when all inputs have been pushed)
                                                  | implicit print TOS


                                                  Reversed:



                                                  @	| push input
                                                  _ | negate
                                                  | implicit print TOS





                                                  share|improve this answer












                                                  $endgroup$

















                                                    4















                                                    4











                                                    4







                                                    $begingroup$


                                                    Gaia, 2 bytes



                                                    _@


                                                    Try it online!



                                                    _	| implicit push input and negate
                                                    @ | push next input OR push last input (when all inputs have been pushed)
                                                    | implicit print TOS


                                                    Reversed:



                                                    @	| push input
                                                    _ | negate
                                                    | implicit print TOS





                                                    share|improve this answer












                                                    $endgroup$




                                                    Gaia, 2 bytes



                                                    _@


                                                    Try it online!



                                                    _	| implicit push input and negate
                                                    @ | push next input OR push last input (when all inputs have been pushed)
                                                    | implicit print TOS


                                                    Reversed:



                                                    @	| push input
                                                    _ | negate
                                                    | implicit print TOS






                                                    share|improve this answer















                                                    share|improve this answer




                                                    share|improve this answer








                                                    edited Sep 18 at 19:55

























                                                    answered Sep 17 at 19:39









                                                    GiuseppeGiuseppe

                                                    20.1k3 gold badges16 silver badges72 bronze badges




                                                    20.1k3 gold badges16 silver badges72 bronze badges
























                                                        4

















                                                        $begingroup$


                                                        Backhand, 6 5 bytes



                                                        I@-Ov


                                                        Try it online! Try it doubled!



                                                        Made a little complex due to the nature of the pointer in Backhand. I don't think it's possible to get any shorter haha, turns out I was wrong. This duplicates no instruction and reuses both the input, output and terminate commands between the two programs. Now I think it is optimal, since you need all of the IO-@ commands to work, and in a 4 byte program you can only execute two of those commands.



                                                        Explanation:



                                                        The pointer in Backhand moves at three cells a tick and bounces off the boundaries of the cell, which means the general logic is overlapping. However you can manipulate this speed with the v and ^ commands.



                                                        The original program executes the instructions IO-@, which is input as number, output as number, subtract, terminate. Obviously the subtract is superfluous. In the code these are:



                                                        I@-Ov
                                                        ^ ^ Reflect
                                                        ^ Reflect again
                                                        ^


                                                        The reversed program executes v-I-vO-@. The v reduces the pointer steps between ticks, and the - subtracts from the bottom of the stack, which is implicitly zero. The extra - commands do nothing. The program executes like



                                                        vO-@I
                                                        v Reduce pointer speed to 2
                                                        - Subtract zero from zero
                                                        I Get input as number and reflect off boundary
                                                        - Subtract input from zero
                                                        v Reduce pointer speed to 1
                                                        O Output as number
                                                        - Subtract zero from zero
                                                        @ Terminate






                                                        share|improve this answer












                                                        $endgroup$



















                                                          4

















                                                          $begingroup$


                                                          Backhand, 6 5 bytes



                                                          I@-Ov


                                                          Try it online! Try it doubled!



                                                          Made a little complex due to the nature of the pointer in Backhand. I don't think it's possible to get any shorter haha, turns out I was wrong. This duplicates no instruction and reuses both the input, output and terminate commands between the two programs. Now I think it is optimal, since you need all of the IO-@ commands to work, and in a 4 byte program you can only execute two of those commands.



                                                          Explanation:



                                                          The pointer in Backhand moves at three cells a tick and bounces off the boundaries of the cell, which means the general logic is overlapping. However you can manipulate this speed with the v and ^ commands.



                                                          The original program executes the instructions IO-@, which is input as number, output as number, subtract, terminate. Obviously the subtract is superfluous. In the code these are:



                                                          I@-Ov
                                                          ^ ^ Reflect
                                                          ^ Reflect again
                                                          ^


                                                          The reversed program executes v-I-vO-@. The v reduces the pointer steps between ticks, and the - subtracts from the bottom of the stack, which is implicitly zero. The extra - commands do nothing. The program executes like



                                                          vO-@I
                                                          v Reduce pointer speed to 2
                                                          - Subtract zero from zero
                                                          I Get input as number and reflect off boundary
                                                          - Subtract input from zero
                                                          v Reduce pointer speed to 1
                                                          O Output as number
                                                          - Subtract zero from zero
                                                          @ Terminate






                                                          share|improve this answer












                                                          $endgroup$

















                                                            4















                                                            4











                                                            4







                                                            $begingroup$


                                                            Backhand, 6 5 bytes



                                                            I@-Ov


                                                            Try it online! Try it doubled!



                                                            Made a little complex due to the nature of the pointer in Backhand. I don't think it's possible to get any shorter haha, turns out I was wrong. This duplicates no instruction and reuses both the input, output and terminate commands between the two programs. Now I think it is optimal, since you need all of the IO-@ commands to work, and in a 4 byte program you can only execute two of those commands.



                                                            Explanation:



                                                            The pointer in Backhand moves at three cells a tick and bounces off the boundaries of the cell, which means the general logic is overlapping. However you can manipulate this speed with the v and ^ commands.



                                                            The original program executes the instructions IO-@, which is input as number, output as number, subtract, terminate. Obviously the subtract is superfluous. In the code these are:



                                                            I@-Ov
                                                            ^ ^ Reflect
                                                            ^ Reflect again
                                                            ^


                                                            The reversed program executes v-I-vO-@. The v reduces the pointer steps between ticks, and the - subtracts from the bottom of the stack, which is implicitly zero. The extra - commands do nothing. The program executes like



                                                            vO-@I
                                                            v Reduce pointer speed to 2
                                                            - Subtract zero from zero
                                                            I Get input as number and reflect off boundary
                                                            - Subtract input from zero
                                                            v Reduce pointer speed to 1
                                                            O Output as number
                                                            - Subtract zero from zero
                                                            @ Terminate






                                                            share|improve this answer












                                                            $endgroup$




                                                            Backhand, 6 5 bytes



                                                            I@-Ov


                                                            Try it online! Try it doubled!



                                                            Made a little complex due to the nature of the pointer in Backhand. I don't think it's possible to get any shorter haha, turns out I was wrong. This duplicates no instruction and reuses both the input, output and terminate commands between the two programs. Now I think it is optimal, since you need all of the IO-@ commands to work, and in a 4 byte program you can only execute two of those commands.



                                                            Explanation:



                                                            The pointer in Backhand moves at three cells a tick and bounces off the boundaries of the cell, which means the general logic is overlapping. However you can manipulate this speed with the v and ^ commands.



                                                            The original program executes the instructions IO-@, which is input as number, output as number, subtract, terminate. Obviously the subtract is superfluous. In the code these are:



                                                            I@-Ov
                                                            ^ ^ Reflect
                                                            ^ Reflect again
                                                            ^


                                                            The reversed program executes v-I-vO-@. The v reduces the pointer steps between ticks, and the - subtracts from the bottom of the stack, which is implicitly zero. The extra - commands do nothing. The program executes like



                                                            vO-@I
                                                            v Reduce pointer speed to 2
                                                            - Subtract zero from zero
                                                            I Get input as number and reflect off boundary
                                                            - Subtract input from zero
                                                            v Reduce pointer speed to 1
                                                            O Output as number
                                                            - Subtract zero from zero
                                                            @ Terminate







                                                            share|improve this answer















                                                            share|improve this answer




                                                            share|improve this answer








                                                            edited Sep 18 at 21:49

























                                                            answered Sep 18 at 7:03









                                                            Jo KingJo King

                                                            36k4 gold badges78 silver badges151 bronze badges




                                                            36k4 gold badges78 silver badges151 bronze badges
























                                                                3

















                                                                $begingroup$


                                                                Wolfram Language (Mathematica), 9 bytes



                                                                1&0+#-0&1


                                                                Try it online!



                                                                Forward: read ((1)&*0+#-0)&*1=#&



                                                                Backward: read ((1)&*0-#+0)&*1=-#&






                                                                share|improve this answer












                                                                $endgroup$



















                                                                  3

















                                                                  $begingroup$


                                                                  Wolfram Language (Mathematica), 9 bytes



                                                                  1&0+#-0&1


                                                                  Try it online!



                                                                  Forward: read ((1)&*0+#-0)&*1=#&



                                                                  Backward: read ((1)&*0-#+0)&*1=-#&






                                                                  share|improve this answer












                                                                  $endgroup$

















                                                                    3















                                                                    3











                                                                    3







                                                                    $begingroup$


                                                                    Wolfram Language (Mathematica), 9 bytes



                                                                    1&0+#-0&1


                                                                    Try it online!



                                                                    Forward: read ((1)&*0+#-0)&*1=#&



                                                                    Backward: read ((1)&*0-#+0)&*1=-#&






                                                                    share|improve this answer












                                                                    $endgroup$




                                                                    Wolfram Language (Mathematica), 9 bytes



                                                                    1&0+#-0&1


                                                                    Try it online!



                                                                    Forward: read ((1)&*0+#-0)&*1=#&



                                                                    Backward: read ((1)&*0-#+0)&*1=-#&







                                                                    share|improve this answer















                                                                    share|improve this answer




                                                                    share|improve this answer








                                                                    edited Sep 18 at 0:35

























                                                                    answered Sep 18 at 0:20









                                                                    attinatattinat

                                                                    3,4253 silver badges11 bronze badges




                                                                    3,4253 silver badges11 bronze badges
























                                                                        3

















                                                                        $begingroup$


                                                                        R, 14 bytes





                                                                        scan()#)(nacs-


                                                                        Try it online!



                                                                        A full program that reads a number, or reads and negates a number. The reverse functionality is protected by an inline comment






                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          Your brackets are the wrong way around in the commented part.
                                                                          $endgroup$
                                                                          – Aaron Hayman
                                                                          Sep 18 at 22:17










                                                                        • $begingroup$
                                                                          @AaronHayman thanks!
                                                                          $endgroup$
                                                                          – Nick Kennedy
                                                                          Sep 18 at 22:29















                                                                        3

















                                                                        $begingroup$


                                                                        R, 14 bytes





                                                                        scan()#)(nacs-


                                                                        Try it online!



                                                                        A full program that reads a number, or reads and negates a number. The reverse functionality is protected by an inline comment






                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          Your brackets are the wrong way around in the commented part.
                                                                          $endgroup$
                                                                          – Aaron Hayman
                                                                          Sep 18 at 22:17










                                                                        • $begingroup$
                                                                          @AaronHayman thanks!
                                                                          $endgroup$
                                                                          – Nick Kennedy
                                                                          Sep 18 at 22:29













                                                                        3















                                                                        3











                                                                        3







                                                                        $begingroup$


                                                                        R, 14 bytes





                                                                        scan()#)(nacs-


                                                                        Try it online!



                                                                        A full program that reads a number, or reads and negates a number. The reverse functionality is protected by an inline comment






                                                                        share|improve this answer












                                                                        $endgroup$




                                                                        R, 14 bytes





                                                                        scan()#)(nacs-


                                                                        Try it online!



                                                                        A full program that reads a number, or reads and negates a number. The reverse functionality is protected by an inline comment







                                                                        share|improve this answer















                                                                        share|improve this answer




                                                                        share|improve this answer








                                                                        edited Sep 18 at 22:28

























                                                                        answered Sep 18 at 5:10









                                                                        Nick KennedyNick Kennedy

                                                                        8,2061 gold badge9 silver badges22 bronze badges




                                                                        8,2061 gold badge9 silver badges22 bronze badges














                                                                        • $begingroup$
                                                                          Your brackets are the wrong way around in the commented part.
                                                                          $endgroup$
                                                                          – Aaron Hayman
                                                                          Sep 18 at 22:17










                                                                        • $begingroup$
                                                                          @AaronHayman thanks!
                                                                          $endgroup$
                                                                          – Nick Kennedy
                                                                          Sep 18 at 22:29
















                                                                        • $begingroup$
                                                                          Your brackets are the wrong way around in the commented part.
                                                                          $endgroup$
                                                                          – Aaron Hayman
                                                                          Sep 18 at 22:17










                                                                        • $begingroup$
                                                                          @AaronHayman thanks!
                                                                          $endgroup$
                                                                          – Nick Kennedy
                                                                          Sep 18 at 22:29















                                                                        $begingroup$
                                                                        Your brackets are the wrong way around in the commented part.
                                                                        $endgroup$
                                                                        – Aaron Hayman
                                                                        Sep 18 at 22:17




                                                                        $begingroup$
                                                                        Your brackets are the wrong way around in the commented part.
                                                                        $endgroup$
                                                                        – Aaron Hayman
                                                                        Sep 18 at 22:17












                                                                        $begingroup$
                                                                        @AaronHayman thanks!
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Sep 18 at 22:29




                                                                        $begingroup$
                                                                        @AaronHayman thanks!
                                                                        $endgroup$
                                                                        – Nick Kennedy
                                                                        Sep 18 at 22:29











                                                                        3

















                                                                        $begingroup$


                                                                        Python 3, 22 14 bytes





                                                                        int#__bus__. 0


                                                                        Try it online!



                                                                        Uses the int class's constructor and a built-in pseudo-private method.






                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          Huh. Why is the space before the attribute mandatory?
                                                                          $endgroup$
                                                                          – Jo King
                                                                          Sep 19 at 1:25







                                                                        • 2




                                                                          $begingroup$
                                                                          @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                          $endgroup$
                                                                          – attinat
                                                                          Sep 19 at 8:22















                                                                        3

















                                                                        $begingroup$


                                                                        Python 3, 22 14 bytes





                                                                        int#__bus__. 0


                                                                        Try it online!



                                                                        Uses the int class's constructor and a built-in pseudo-private method.






                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          Huh. Why is the space before the attribute mandatory?
                                                                          $endgroup$
                                                                          – Jo King
                                                                          Sep 19 at 1:25







                                                                        • 2




                                                                          $begingroup$
                                                                          @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                          $endgroup$
                                                                          – attinat
                                                                          Sep 19 at 8:22













                                                                        3















                                                                        3











                                                                        3







                                                                        $begingroup$


                                                                        Python 3, 22 14 bytes





                                                                        int#__bus__. 0


                                                                        Try it online!



                                                                        Uses the int class's constructor and a built-in pseudo-private method.






                                                                        share|improve this answer












                                                                        $endgroup$




                                                                        Python 3, 22 14 bytes





                                                                        int#__bus__. 0


                                                                        Try it online!



                                                                        Uses the int class's constructor and a built-in pseudo-private method.







                                                                        share|improve this answer















                                                                        share|improve this answer




                                                                        share|improve this answer








                                                                        edited Sep 19 at 17:21

























                                                                        answered Sep 18 at 22:31









                                                                        mypetlionmypetlion

                                                                        6902 silver badges11 bronze badges




                                                                        6902 silver badges11 bronze badges














                                                                        • $begingroup$
                                                                          Huh. Why is the space before the attribute mandatory?
                                                                          $endgroup$
                                                                          – Jo King
                                                                          Sep 19 at 1:25







                                                                        • 2




                                                                          $begingroup$
                                                                          @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                          $endgroup$
                                                                          – attinat
                                                                          Sep 19 at 8:22
















                                                                        • $begingroup$
                                                                          Huh. Why is the space before the attribute mandatory?
                                                                          $endgroup$
                                                                          – Jo King
                                                                          Sep 19 at 1:25







                                                                        • 2




                                                                          $begingroup$
                                                                          @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                          $endgroup$
                                                                          – attinat
                                                                          Sep 19 at 8:22















                                                                        $begingroup$
                                                                        Huh. Why is the space before the attribute mandatory?
                                                                        $endgroup$
                                                                        – Jo King
                                                                        Sep 19 at 1:25





                                                                        $begingroup$
                                                                        Huh. Why is the space before the attribute mandatory?
                                                                        $endgroup$
                                                                        – Jo King
                                                                        Sep 19 at 1:25





                                                                        2




                                                                        2




                                                                        $begingroup$
                                                                        @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                        $endgroup$
                                                                        – attinat
                                                                        Sep 19 at 8:22




                                                                        $begingroup$
                                                                        @JoKing 0. would be interpreted as a number, which is followed by a symbol
                                                                        $endgroup$
                                                                        – attinat
                                                                        Sep 19 at 8:22











                                                                        2

















                                                                        $begingroup$


                                                                        05AB1E, 2 bytes



                                                                        (I


                                                                        Try it online!



                                                                        Reversed



                                                                        ( negates nothing
                                                                        I pushes input

                                                                        I pushes input
                                                                        ( negates input





                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                          $endgroup$
                                                                          – Adám
                                                                          Sep 17 at 19:49










                                                                        • $begingroup$
                                                                          My bad, I misunderstood
                                                                          $endgroup$
                                                                          – jasanborn
                                                                          Sep 17 at 19:52















                                                                        2

















                                                                        $begingroup$


                                                                        05AB1E, 2 bytes



                                                                        (I


                                                                        Try it online!



                                                                        Reversed



                                                                        ( negates nothing
                                                                        I pushes input

                                                                        I pushes input
                                                                        ( negates input





                                                                        share|improve this answer












                                                                        $endgroup$














                                                                        • $begingroup$
                                                                          It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                          $endgroup$
                                                                          – Adám
                                                                          Sep 17 at 19:49










                                                                        • $begingroup$
                                                                          My bad, I misunderstood
                                                                          $endgroup$
                                                                          – jasanborn
                                                                          Sep 17 at 19:52













                                                                        2















                                                                        2











                                                                        2







                                                                        $begingroup$


                                                                        05AB1E, 2 bytes



                                                                        (I


                                                                        Try it online!



                                                                        Reversed



                                                                        ( negates nothing
                                                                        I pushes input

                                                                        I pushes input
                                                                        ( negates input





                                                                        share|improve this answer












                                                                        $endgroup$




                                                                        05AB1E, 2 bytes



                                                                        (I


                                                                        Try it online!



                                                                        Reversed



                                                                        ( negates nothing
                                                                        I pushes input

                                                                        I pushes input
                                                                        ( negates input






                                                                        share|improve this answer















                                                                        share|improve this answer




                                                                        share|improve this answer








                                                                        edited Sep 17 at 19:57

























                                                                        answered Sep 17 at 19:48









                                                                        jasanbornjasanborn

                                                                        214 bronze badges




                                                                        214 bronze badges














                                                                        • $begingroup$
                                                                          It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                          $endgroup$
                                                                          – Adám
                                                                          Sep 17 at 19:49










                                                                        • $begingroup$
                                                                          My bad, I misunderstood
                                                                          $endgroup$
                                                                          – jasanborn
                                                                          Sep 17 at 19:52
















                                                                        • $begingroup$
                                                                          It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                          $endgroup$
                                                                          – Adám
                                                                          Sep 17 at 19:49










                                                                        • $begingroup$
                                                                          My bad, I misunderstood
                                                                          $endgroup$
                                                                          – jasanborn
                                                                          Sep 17 at 19:52















                                                                        $begingroup$
                                                                        It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                        $endgroup$
                                                                        – Adám
                                                                        Sep 17 at 19:49




                                                                        $begingroup$
                                                                        It is supposed to only negate the input in one direction, leaving it as-is in the other. Clearly, 1-character solution cannot be valid.
                                                                        $endgroup$
                                                                        – Adám
                                                                        Sep 17 at 19:49












                                                                        $begingroup$
                                                                        My bad, I misunderstood
                                                                        $endgroup$
                                                                        – jasanborn
                                                                        Sep 17 at 19:52




                                                                        $begingroup$
                                                                        My bad, I misunderstood
                                                                        $endgroup$
                                                                        – jasanborn
                                                                        Sep 17 at 19:52











                                                                        2

















                                                                        $begingroup$


                                                                        Befunge-98 (FBBI), 6 bytes



                                                                        &.@.-&


                                                                        Try it online! Try it reversed!






                                                                        share|improve this answer










                                                                        $endgroup$



















                                                                          2

















                                                                          $begingroup$


                                                                          Befunge-98 (FBBI), 6 bytes



                                                                          &.@.-&


                                                                          Try it online! Try it reversed!






                                                                          share|improve this answer










                                                                          $endgroup$

















                                                                            2















                                                                            2











                                                                            2







                                                                            $begingroup$


                                                                            Befunge-98 (FBBI), 6 bytes



                                                                            &.@.-&


                                                                            Try it online! Try it reversed!






                                                                            share|improve this answer










                                                                            $endgroup$




                                                                            Befunge-98 (FBBI), 6 bytes



                                                                            &.@.-&


                                                                            Try it online! Try it reversed!







                                                                            share|improve this answer













                                                                            share|improve this answer




                                                                            share|improve this answer










                                                                            answered Sep 17 at 21:15









                                                                            ovsovs

                                                                            20.6k2 gold badges13 silver badges66 bronze badges




                                                                            20.6k2 gold badges13 silver badges66 bronze badges
























                                                                                2

















                                                                                $begingroup$


                                                                                APL (Dyalog Unicode), 13 3 bytes





                                                                                -∘0


                                                                                Try it online!



                                                                                Trivial answer. Returns arg or ¯arg.



                                                                                Saved 10 bytes by not being dumb (thanks Adám).



                                                                                Altered the resulting 3-byter to a more fitting function.






                                                                                share|improve this answer












                                                                                $endgroup$














                                                                                • $begingroup$
                                                                                  Whoa, this can be done trivially in three bytes!
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 17 at 20:31










                                                                                • $begingroup$
                                                                                  Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 18 at 9:01










                                                                                • $begingroup$
                                                                                  @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                  $endgroup$
                                                                                  – J. Sallé
                                                                                  Sep 18 at 12:54















                                                                                2

















                                                                                $begingroup$


                                                                                APL (Dyalog Unicode), 13 3 bytes





                                                                                -∘0


                                                                                Try it online!



                                                                                Trivial answer. Returns arg or ¯arg.



                                                                                Saved 10 bytes by not being dumb (thanks Adám).



                                                                                Altered the resulting 3-byter to a more fitting function.






                                                                                share|improve this answer












                                                                                $endgroup$














                                                                                • $begingroup$
                                                                                  Whoa, this can be done trivially in three bytes!
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 17 at 20:31










                                                                                • $begingroup$
                                                                                  Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 18 at 9:01










                                                                                • $begingroup$
                                                                                  @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                  $endgroup$
                                                                                  – J. Sallé
                                                                                  Sep 18 at 12:54













                                                                                2















                                                                                2











                                                                                2







                                                                                $begingroup$


                                                                                APL (Dyalog Unicode), 13 3 bytes





                                                                                -∘0


                                                                                Try it online!



                                                                                Trivial answer. Returns arg or ¯arg.



                                                                                Saved 10 bytes by not being dumb (thanks Adám).



                                                                                Altered the resulting 3-byter to a more fitting function.






                                                                                share|improve this answer












                                                                                $endgroup$




                                                                                APL (Dyalog Unicode), 13 3 bytes





                                                                                -∘0


                                                                                Try it online!



                                                                                Trivial answer. Returns arg or ¯arg.



                                                                                Saved 10 bytes by not being dumb (thanks Adám).



                                                                                Altered the resulting 3-byter to a more fitting function.







                                                                                share|improve this answer















                                                                                share|improve this answer




                                                                                share|improve this answer








                                                                                edited Sep 18 at 13:00

























                                                                                answered Sep 17 at 20:22









                                                                                J. SalléJ. Sallé

                                                                                3,1934 silver badges24 bronze badges




                                                                                3,1934 silver badges24 bronze badges














                                                                                • $begingroup$
                                                                                  Whoa, this can be done trivially in three bytes!
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 17 at 20:31










                                                                                • $begingroup$
                                                                                  Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 18 at 9:01










                                                                                • $begingroup$
                                                                                  @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                  $endgroup$
                                                                                  – J. Sallé
                                                                                  Sep 18 at 12:54
















                                                                                • $begingroup$
                                                                                  Whoa, this can be done trivially in three bytes!
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 17 at 20:31










                                                                                • $begingroup$
                                                                                  Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                  $endgroup$
                                                                                  – Adám
                                                                                  Sep 18 at 9:01










                                                                                • $begingroup$
                                                                                  @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                  $endgroup$
                                                                                  – J. Sallé
                                                                                  Sep 18 at 12:54















                                                                                $begingroup$
                                                                                Whoa, this can be done trivially in three bytes!
                                                                                $endgroup$
                                                                                – Adám
                                                                                Sep 17 at 20:31




                                                                                $begingroup$
                                                                                Whoa, this can be done trivially in three bytes!
                                                                                $endgroup$
                                                                                – Adám
                                                                                Sep 17 at 20:31












                                                                                $begingroup$
                                                                                Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                $endgroup$
                                                                                – Adám
                                                                                Sep 18 at 9:01




                                                                                $begingroup$
                                                                                Interestingly, you already have a 3-byte answer embedded as a substring of this.
                                                                                $endgroup$
                                                                                – Adám
                                                                                Sep 18 at 9:01












                                                                                $begingroup$
                                                                                @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                $endgroup$
                                                                                – J. Sallé
                                                                                Sep 18 at 12:54




                                                                                $begingroup$
                                                                                @Adám yeah, I knew there was a simple answer in there somewhere. Thanks.
                                                                                $endgroup$
                                                                                – J. Sallé
                                                                                Sep 18 at 12:54











                                                                                2

















                                                                                $begingroup$


                                                                                Turing Machine Language, 39 bytes



                                                                                The Positive



                                                                                1 r - _ 0
                                                                                0 l * * 0
                                                                                0 - _ l 0
                                                                                0 _ _ r 0


                                                                                The Negative



                                                                                0 r _ _ 0
                                                                                0 l _ - 0
                                                                                0 * * l 0
                                                                                0 _ - r 1


                                                                                This one was a bit trickier than I thought, mostly because I had to get past my prejudices of having code that runs with 'compile' errors.






                                                                                share|improve this answer












                                                                                $endgroup$



















                                                                                  2

















                                                                                  $begingroup$


                                                                                  Turing Machine Language, 39 bytes



                                                                                  The Positive



                                                                                  1 r - _ 0
                                                                                  0 l * * 0
                                                                                  0 - _ l 0
                                                                                  0 _ _ r 0


                                                                                  The Negative



                                                                                  0 r _ _ 0
                                                                                  0 l _ - 0
                                                                                  0 * * l 0
                                                                                  0 _ - r 1


                                                                                  This one was a bit trickier than I thought, mostly because I had to get past my prejudices of having code that runs with 'compile' errors.






                                                                                  share|improve this answer












                                                                                  $endgroup$

















                                                                                    2















                                                                                    2











                                                                                    2







                                                                                    $begingroup$


                                                                                    Turing Machine Language, 39 bytes



                                                                                    The Positive



                                                                                    1 r - _ 0
                                                                                    0 l * * 0
                                                                                    0 - _ l 0
                                                                                    0 _ _ r 0


                                                                                    The Negative



                                                                                    0 r _ _ 0
                                                                                    0 l _ - 0
                                                                                    0 * * l 0
                                                                                    0 _ - r 1


                                                                                    This one was a bit trickier than I thought, mostly because I had to get past my prejudices of having code that runs with 'compile' errors.






                                                                                    share|improve this answer












                                                                                    $endgroup$




                                                                                    Turing Machine Language, 39 bytes



                                                                                    The Positive



                                                                                    1 r - _ 0
                                                                                    0 l * * 0
                                                                                    0 - _ l 0
                                                                                    0 _ _ r 0


                                                                                    The Negative



                                                                                    0 r _ _ 0
                                                                                    0 l _ - 0
                                                                                    0 * * l 0
                                                                                    0 _ - r 1


                                                                                    This one was a bit trickier than I thought, mostly because I had to get past my prejudices of having code that runs with 'compile' errors.







                                                                                    share|improve this answer















                                                                                    share|improve this answer




                                                                                    share|improve this answer








                                                                                    edited Sep 18 at 13:08

























                                                                                    answered Sep 18 at 11:59









                                                                                    ouflakouflak

                                                                                    7751 gold badge5 silver badges18 bronze badges




                                                                                    7751 gold badge5 silver badges18 bronze badges
























                                                                                        2

















                                                                                        $begingroup$


                                                                                        ><>, 5 4 bytes



                                                                                        n-r0


                                                                                        uses stack initialisation with the -v option, put your input variable there.



                                                                                        Try it online!



                                                                                        Or try the reversal



                                                                                        Explanation



                                                                                        n Prints whatever is on the stack as a number
                                                                                        - Subtract the top 2 elements on the stack.
                                                                                        There aren't 2 elements, so it crashes.
                                                                                        r0 Never gets executed

                                                                                        or reversed:

                                                                                        0 Push a 0 onto the stack
                                                                                        r reverse the stack (now 0, -v)
                                                                                        - Subtract top 2 elements and push result (0-v, ie negated)
                                                                                        n Print as number
                                                                                        The code wraps around and executes again.
                                                                                        It crashes on the - as there is only one
                                                                                        item on the stack: 0.





                                                                                        share|improve this answer












                                                                                        $endgroup$



















                                                                                          2

















                                                                                          $begingroup$


                                                                                          ><>, 5 4 bytes



                                                                                          n-r0


                                                                                          uses stack initialisation with the -v option, put your input variable there.



                                                                                          Try it online!



                                                                                          Or try the reversal



                                                                                          Explanation



                                                                                          n Prints whatever is on the stack as a number
                                                                                          - Subtract the top 2 elements on the stack.
                                                                                          There aren't 2 elements, so it crashes.
                                                                                          r0 Never gets executed

                                                                                          or reversed:

                                                                                          0 Push a 0 onto the stack
                                                                                          r reverse the stack (now 0, -v)
                                                                                          - Subtract top 2 elements and push result (0-v, ie negated)
                                                                                          n Print as number
                                                                                          The code wraps around and executes again.
                                                                                          It crashes on the - as there is only one
                                                                                          item on the stack: 0.





                                                                                          share|improve this answer












                                                                                          $endgroup$

















                                                                                            2















                                                                                            2











                                                                                            2







                                                                                            $begingroup$


                                                                                            ><>, 5 4 bytes



                                                                                            n-r0


                                                                                            uses stack initialisation with the -v option, put your input variable there.



                                                                                            Try it online!



                                                                                            Or try the reversal



                                                                                            Explanation



                                                                                            n Prints whatever is on the stack as a number
                                                                                            - Subtract the top 2 elements on the stack.
                                                                                            There aren't 2 elements, so it crashes.
                                                                                            r0 Never gets executed

                                                                                            or reversed:

                                                                                            0 Push a 0 onto the stack
                                                                                            r reverse the stack (now 0, -v)
                                                                                            - Subtract top 2 elements and push result (0-v, ie negated)
                                                                                            n Print as number
                                                                                            The code wraps around and executes again.
                                                                                            It crashes on the - as there is only one
                                                                                            item on the stack: 0.





                                                                                            share|improve this answer












                                                                                            $endgroup$




                                                                                            ><>, 5 4 bytes



                                                                                            n-r0


                                                                                            uses stack initialisation with the -v option, put your input variable there.



                                                                                            Try it online!



                                                                                            Or try the reversal



                                                                                            Explanation



                                                                                            n Prints whatever is on the stack as a number
                                                                                            - Subtract the top 2 elements on the stack.
                                                                                            There aren't 2 elements, so it crashes.
                                                                                            r0 Never gets executed

                                                                                            or reversed:

                                                                                            0 Push a 0 onto the stack
                                                                                            r reverse the stack (now 0, -v)
                                                                                            - Subtract top 2 elements and push result (0-v, ie negated)
                                                                                            n Print as number
                                                                                            The code wraps around and executes again.
                                                                                            It crashes on the - as there is only one
                                                                                            item on the stack: 0.






                                                                                            share|improve this answer















                                                                                            share|improve this answer




                                                                                            share|improve this answer








                                                                                            edited Sep 19 at 7:27

























                                                                                            answered Sep 18 at 15:20









                                                                                            steenberghsteenbergh

                                                                                            7,7541 gold badge18 silver badges39 bronze badges




                                                                                            7,7541 gold badge18 silver badges39 bronze badges
























                                                                                                2

















                                                                                                $begingroup$


                                                                                                Stack Cats -mn, 2 bytes



                                                                                                -X


                                                                                                Try it online!



                                                                                                Try the reverse!



                                                                                                Explanation



                                                                                                Turns out this is actually a lot easier than the previous challenge in Stack Cats. The full program (after applying -m) here is -X-. X is used to swap the stacks left and right of the tape head, i.e. it doesn't affect the initial stack at all, so we can ignore it. But then the program is effectively just -- (negate the top of the stack twice), which does nothing.



                                                                                                For the inverse program, applying -m gives X-X. Again, X does nothing, so the program is effectively just -, which negates the top of the stack.



                                                                                                The only other 2-byte solution is -=, but it's virtually the same. The only difference is that = swaps only the tops of the adjacent stacks, not the entire stacks.



                                                                                                But again, using -m feels a bit like cheating, so below is a solution that uses a fully mirrored program.





                                                                                                Stack Cats -n, 7 bytes



                                                                                                :I<->I:


                                                                                                Try it online!



                                                                                                Try the reverse!



                                                                                                Explanation



                                                                                                The considerations from the previous answer still apply: any valid solution needs to use the paired characters and I. The six possible solutions (included in the TIO link) are all virtually the same. - and _ are equivalent in this program, and : can be replaced by | or T (which do the same for non-zero inputs and coincidentally also work for zero inputs). I've just picked this one to explain because it's easiest.



                                                                                                So remember that the initial stack holds the input on top of a -1 (on top of infinitely many zeros) whereas all the other stacks along the tape only hold zeros. Stack Cats also has the property that any even-length program does nothing (provided it terminates, but we can't use loops for this challenge anyway). The same is then obviously true for any odd-length program whose centre character does nothing... let's see:



                                                                                                : Swap the input with the -1 below.
                                                                                                I Move the -1 one stack to the left and turn it into +1.
                                                                                                < Move another stack left (without taking the value).
                                                                                                - Negate the zero on top of that stack (i.e. do nothing).


                                                                                                Therefore, the second half of the program exactly undoes the first half and we end up with the input on top of a -1 again.



                                                                                                The inverse program is :I>-<I:. Let's see how that changes things:



                                                                                                : Swap the input with the -1 below.
                                                                                                I Move the -1 one stack to the left and turn it into +1.
                                                                                                > Move one stack right, i.e. back onto the initial stack which still holds the input.
                                                                                                - Negate the input.
                                                                                                < Move back to the left where we've parked the 1.
                                                                                                I Move that 1 back onto the initial stack and turn it back into a -1.
                                                                                                : Swap the -1 below the negated input to act as an EOF marker.





                                                                                                share|improve this answer










                                                                                                $endgroup$



















                                                                                                  2

















                                                                                                  $begingroup$


                                                                                                  Stack Cats -mn, 2 bytes



                                                                                                  -X


                                                                                                  Try it online!



                                                                                                  Try the reverse!



                                                                                                  Explanation



                                                                                                  Turns out this is actually a lot easier than the previous challenge in Stack Cats. The full program (after applying -m) here is -X-. X is used to swap the stacks left and right of the tape head, i.e. it doesn't affect the initial stack at all, so we can ignore it. But then the program is effectively just -- (negate the top of the stack twice), which does nothing.



                                                                                                  For the inverse program, applying -m gives X-X. Again, X does nothing, so the program is effectively just -, which negates the top of the stack.



                                                                                                  The only other 2-byte solution is -=, but it's virtually the same. The only difference is that = swaps only the tops of the adjacent stacks, not the entire stacks.



                                                                                                  But again, using -m feels a bit like cheating, so below is a solution that uses a fully mirrored program.





                                                                                                  Stack Cats -n, 7 bytes



                                                                                                  :I<->I:


                                                                                                  Try it online!



                                                                                                  Try the reverse!



                                                                                                  Explanation



                                                                                                  The considerations from the previous answer still apply: any valid solution needs to use the paired characters and I. The six possible solutions (included in the TIO link) are all virtually the same. - and _ are equivalent in this program, and : can be replaced by | or T (which do the same for non-zero inputs and coincidentally also work for zero inputs). I've just picked this one to explain because it's easiest.



                                                                                                  So remember that the initial stack holds the input on top of a -1 (on top of infinitely many zeros) whereas all the other stacks along the tape only hold zeros. Stack Cats also has the property that any even-length program does nothing (provided it terminates, but we can't use loops for this challenge anyway). The same is then obviously true for any odd-length program whose centre character does nothing... let's see:



                                                                                                  : Swap the input with the -1 below.
                                                                                                  I Move the -1 one stack to the left and turn it into +1.
                                                                                                  < Move another stack left (without taking the value).
                                                                                                  - Negate the zero on top of that stack (i.e. do nothing).


                                                                                                  Therefore, the second half of the program exactly undoes the first half and we end up with the input on top of a -1 again.



                                                                                                  The inverse program is :I>-<I:. Let's see how that changes things:



                                                                                                  : Swap the input with the -1 below.
                                                                                                  I Move the -1 one stack to the left and turn it into +1.
                                                                                                  > Move one stack right, i.e. back onto the initial stack which still holds the input.
                                                                                                  - Negate the input.
                                                                                                  < Move back to the left where we've parked the 1.
                                                                                                  I Move that 1 back onto the initial stack and turn it back into a -1.
                                                                                                  : Swap the -1 below the negated input to act as an EOF marker.





                                                                                                  share|improve this answer










                                                                                                  $endgroup$

















                                                                                                    2















                                                                                                    2











                                                                                                    2







                                                                                                    $begingroup$


                                                                                                    Stack Cats -mn, 2 bytes



                                                                                                    -X


                                                                                                    Try it online!



                                                                                                    Try the reverse!



                                                                                                    Explanation



                                                                                                    Turns out this is actually a lot easier than the previous challenge in Stack Cats. The full program (after applying -m) here is -X-. X is used to swap the stacks left and right of the tape head, i.e. it doesn't affect the initial stack at all, so we can ignore it. But then the program is effectively just -- (negate the top of the stack twice), which does nothing.



                                                                                                    For the inverse program, applying -m gives X-X. Again, X does nothing, so the program is effectively just -, which negates the top of the stack.



                                                                                                    The only other 2-byte solution is -=, but it's virtually the same. The only difference is that = swaps only the tops of the adjacent stacks, not the entire stacks.



                                                                                                    But again, using -m feels a bit like cheating, so below is a solution that uses a fully mirrored program.





                                                                                                    Stack Cats -n, 7 bytes



                                                                                                    :I<->I:


                                                                                                    Try it online!



                                                                                                    Try the reverse!



                                                                                                    Explanation



                                                                                                    The considerations from the previous answer still apply: any valid solution needs to use the paired characters and I. The six possible solutions (included in the TIO link) are all virtually the same. - and _ are equivalent in this program, and : can be replaced by | or T (which do the same for non-zero inputs and coincidentally also work for zero inputs). I've just picked this one to explain because it's easiest.



                                                                                                    So remember that the initial stack holds the input on top of a -1 (on top of infinitely many zeros) whereas all the other stacks along the tape only hold zeros. Stack Cats also has the property that any even-length program does nothing (provided it terminates, but we can't use loops for this challenge anyway). The same is then obviously true for any odd-length program whose centre character does nothing... let's see:



                                                                                                    : Swap the input with the -1 below.
                                                                                                    I Move the -1 one stack to the left and turn it into +1.
                                                                                                    < Move another stack left (without taking the value).
                                                                                                    - Negate the zero on top of that stack (i.e. do nothing).


                                                                                                    Therefore, the second half of the program exactly undoes the first half and we end up with the input on top of a -1 again.



                                                                                                    The inverse program is :I>-<I:. Let's see how that changes things:



                                                                                                    : Swap the input with the -1 below.
                                                                                                    I Move the -1 one stack to the left and turn it into +1.
                                                                                                    > Move one stack right, i.e. back onto the initial stack which still holds the input.
                                                                                                    - Negate the input.
                                                                                                    < Move back to the left where we've parked the 1.
                                                                                                    I Move that 1 back onto the initial stack and turn it back into a -1.
                                                                                                    : Swap the -1 below the negated input to act as an EOF marker.





                                                                                                    share|improve this answer










                                                                                                    $endgroup$




                                                                                                    Stack Cats -mn, 2 bytes



                                                                                                    -X


                                                                                                    Try it online!



                                                                                                    Try the reverse!



                                                                                                    Explanation



                                                                                                    Turns out this is actually a lot easier than the previous challenge in Stack Cats. The full program (after applying -m) here is -X-. X is used to swap the stacks left and right of the tape head, i.e. it doesn't affect the initial stack at all, so we can ignore it. But then the program is effectively just -- (negate the top of the stack twice), which does nothing.



                                                                                                    For the inverse program, applying -m gives X-X. Again, X does nothing, so the program is effectively just -, which negates the top of the stack.



                                                                                                    The only other 2-byte solution is -=, but it's virtually the same. The only difference is that = swaps only the tops of the adjacent stacks, not the entire stacks.



                                                                                                    But again, using -m feels a bit like cheating, so below is a solution that uses a fully mirrored program.





                                                                                                    Stack Cats -n, 7 bytes



                                                                                                    :I<->I:


                                                                                                    Try it online!



                                                                                                    Try the reverse!



                                                                                                    Explanation



                                                                                                    The considerations from the previous answer still apply: any valid solution needs to use the paired characters and I. The six possible solutions (included in the TIO link) are all virtually the same. - and _ are equivalent in this program, and : can be replaced by | or T (which do the same for non-zero inputs and coincidentally also work for zero inputs). I've just picked this one to explain because it's easiest.



                                                                                                    So remember that the initial stack holds the input on top of a -1 (on top of infinitely many zeros) whereas all the other stacks along the tape only hold zeros. Stack Cats also has the property that any even-length program does nothing (provided it terminates, but we can't use loops for this challenge anyway). The same is then obviously true for any odd-length program whose centre character does nothing... let's see:



                                                                                                    : Swap the input with the -1 below.
                                                                                                    I Move the -1 one stack to the left and turn it into +1.
                                                                                                    < Move another stack left (without taking the value).
                                                                                                    - Negate the zero on top of that stack (i.e. do nothing).


                                                                                                    Therefore, the second half of the program exactly undoes the first half and we end up with the input on top of a -1 again.



                                                                                                    The inverse program is :I>-<I:. Let's see how that changes things:



                                                                                                    : Swap the input with the -1 below.
                                                                                                    I Move the -1 one stack to the left and turn it into +1.
                                                                                                    > Move one stack right, i.e. back onto the initial stack which still holds the input.
                                                                                                    - Negate the input.
                                                                                                    < Move back to the left where we've parked the 1.
                                                                                                    I Move that 1 back onto the initial stack and turn it back into a -1.
                                                                                                    : Swap the -1 below the negated input to act as an EOF marker.






                                                                                                    share|improve this answer













                                                                                                    share|improve this answer




                                                                                                    share|improve this answer










                                                                                                    answered Sep 21 at 10:51









                                                                                                    Martin EnderMartin Ender

                                                                                                    184k61 gold badges407 silver badges890 bronze badges




                                                                                                    184k61 gold badges407 silver badges890 bronze badges
























                                                                                                        2

















                                                                                                        $begingroup$

                                                                                                        Batch, 34 bytes



                                                                                                        @ECHO.%1 2>MER@
                                                                                                        @REM>2 1%=-aa/TES@


                                                                                                        Echoes (ECHO.) the input (%1). The rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).



                                                                                                        Reversed



                                                                                                        @SET/aa-=%1 2>MER@
                                                                                                        @REM>2 1%.OHCE@


                                                                                                        Uses the arithmetic mode of the set command (SET /a) to subtract (-=) the input (%1) from an undefined variable (a) which is equivalent to 0 - input. Again, the rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).






                                                                                                        share|improve this answer












                                                                                                        $endgroup$














                                                                                                        • $begingroup$
                                                                                                          This looks interesting. Care to explain?
                                                                                                          $endgroup$
                                                                                                          – Adám
                                                                                                          Sep 25 at 5:34










                                                                                                        • $begingroup$
                                                                                                          @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                          $endgroup$
                                                                                                          – Οurous
                                                                                                          Sep 25 at 6:34















                                                                                                        2

















                                                                                                        $begingroup$

                                                                                                        Batch, 34 bytes



                                                                                                        @ECHO.%1 2>MER@
                                                                                                        @REM>2 1%=-aa/TES@


                                                                                                        Echoes (ECHO.) the input (%1). The rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).



                                                                                                        Reversed



                                                                                                        @SET/aa-=%1 2>MER@
                                                                                                        @REM>2 1%.OHCE@


                                                                                                        Uses the arithmetic mode of the set command (SET /a) to subtract (-=) the input (%1) from an undefined variable (a) which is equivalent to 0 - input. Again, the rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).






                                                                                                        share|improve this answer












                                                                                                        $endgroup$














                                                                                                        • $begingroup$
                                                                                                          This looks interesting. Care to explain?
                                                                                                          $endgroup$
                                                                                                          – Adám
                                                                                                          Sep 25 at 5:34










                                                                                                        • $begingroup$
                                                                                                          @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                          $endgroup$
                                                                                                          – Οurous
                                                                                                          Sep 25 at 6:34













                                                                                                        2















                                                                                                        2











                                                                                                        2







                                                                                                        $begingroup$

                                                                                                        Batch, 34 bytes



                                                                                                        @ECHO.%1 2>MER@
                                                                                                        @REM>2 1%=-aa/TES@


                                                                                                        Echoes (ECHO.) the input (%1). The rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).



                                                                                                        Reversed



                                                                                                        @SET/aa-=%1 2>MER@
                                                                                                        @REM>2 1%.OHCE@


                                                                                                        Uses the arithmetic mode of the set command (SET /a) to subtract (-=) the input (%1) from an undefined variable (a) which is equivalent to 0 - input. Again, the rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).






                                                                                                        share|improve this answer












                                                                                                        $endgroup$



                                                                                                        Batch, 34 bytes



                                                                                                        @ECHO.%1 2>MER@
                                                                                                        @REM>2 1%=-aa/TES@


                                                                                                        Echoes (ECHO.) the input (%1). The rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).



                                                                                                        Reversed



                                                                                                        @SET/aa-=%1 2>MER@
                                                                                                        @REM>2 1%.OHCE@


                                                                                                        Uses the arithmetic mode of the set command (SET /a) to subtract (-=) the input (%1) from an undefined variable (a) which is equivalent to 0 - input. Again, the rest of the first line technically redirects STDERR to a file called MER@, but this isn't impactful.

                                                                                                        Second line is commented out (REM...).







                                                                                                        share|improve this answer















                                                                                                        share|improve this answer




                                                                                                        share|improve this answer








                                                                                                        edited Sep 25 at 6:32

























                                                                                                        answered Sep 25 at 3:10









                                                                                                        ΟurousΟurous

                                                                                                        7,8961 gold badge11 silver badges36 bronze badges




                                                                                                        7,8961 gold badge11 silver badges36 bronze badges














                                                                                                        • $begingroup$
                                                                                                          This looks interesting. Care to explain?
                                                                                                          $endgroup$
                                                                                                          – Adám
                                                                                                          Sep 25 at 5:34










                                                                                                        • $begingroup$
                                                                                                          @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                          $endgroup$
                                                                                                          – Οurous
                                                                                                          Sep 25 at 6:34
















                                                                                                        • $begingroup$
                                                                                                          This looks interesting. Care to explain?
                                                                                                          $endgroup$
                                                                                                          – Adám
                                                                                                          Sep 25 at 5:34










                                                                                                        • $begingroup$
                                                                                                          @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                          $endgroup$
                                                                                                          – Οurous
                                                                                                          Sep 25 at 6:34















                                                                                                        $begingroup$
                                                                                                        This looks interesting. Care to explain?
                                                                                                        $endgroup$
                                                                                                        – Adám
                                                                                                        Sep 25 at 5:34




                                                                                                        $begingroup$
                                                                                                        This looks interesting. Care to explain?
                                                                                                        $endgroup$
                                                                                                        – Adám
                                                                                                        Sep 25 at 5:34












                                                                                                        $begingroup$
                                                                                                        @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                        $endgroup$
                                                                                                        – Οurous
                                                                                                        Sep 25 at 6:34




                                                                                                        $begingroup$
                                                                                                        @Adám Added an explanation, and also realised that I had the programs around backwards.
                                                                                                        $endgroup$
                                                                                                        – Οurous
                                                                                                        Sep 25 at 6:34











                                                                                                        2

















                                                                                                        $begingroup$


                                                                                                        Brachylog, 2 bytes



                                                                                                        &ṅ


                                                                                                        Brachylog implicitly inputs from the left and outputs from the right.
                                                                                                        & ignores anything to the left and passes the input to the function rightwards.
                                                                                                        constrains each side of it to be negated versions of each other.



                                                                                                        Try it online






                                                                                                        share|improve this answer










                                                                                                        $endgroup$



















                                                                                                          2

















                                                                                                          $begingroup$


                                                                                                          Brachylog, 2 bytes



                                                                                                          &ṅ


                                                                                                          Brachylog implicitly inputs from the left and outputs from the right.
                                                                                                          & ignores anything to the left and passes the input to the function rightwards.
                                                                                                          constrains each side of it to be negated versions of each other.



                                                                                                          Try it online






                                                                                                          share|improve this answer










                                                                                                          $endgroup$

















                                                                                                            2















                                                                                                            2











                                                                                                            2







                                                                                                            $begingroup$


                                                                                                            Brachylog, 2 bytes



                                                                                                            &ṅ


                                                                                                            Brachylog implicitly inputs from the left and outputs from the right.
                                                                                                            & ignores anything to the left and passes the input to the function rightwards.
                                                                                                            constrains each side of it to be negated versions of each other.



                                                                                                            Try it online






                                                                                                            share|improve this answer










                                                                                                            $endgroup$




                                                                                                            Brachylog, 2 bytes



                                                                                                            &ṅ


                                                                                                            Brachylog implicitly inputs from the left and outputs from the right.
                                                                                                            & ignores anything to the left and passes the input to the function rightwards.
                                                                                                            constrains each side of it to be negated versions of each other.



                                                                                                            Try it online







                                                                                                            share|improve this answer













                                                                                                            share|improve this answer




                                                                                                            share|improve this answer










                                                                                                            answered Oct 12 at 7:36









                                                                                                            IFcoltransGIFcoltransG

                                                                                                            1915 bronze badges




                                                                                                            1915 bronze badges
























                                                                                                                2

















                                                                                                                $begingroup$


                                                                                                                Triangular, 8 7 bytes



                                                                                                                $%%.|.$


                                                                                                                Try it online!



                                                                                                                Ungolfed:



                                                                                                                 $ | $: Read an Integer
                                                                                                                % % | %: Output it
                                                                                                                . | .
                                                                                                                $


                                                                                                                Reversed:



                                                                                                                $.|.%%$


                                                                                                                Try it online!



                                                                                                                Previous Version (8 bytes):



                                                                                                                $.%..|.$





                                                                                                                share|improve this answer












                                                                                                                $endgroup$



















                                                                                                                  2

















                                                                                                                  $begingroup$


                                                                                                                  Triangular, 8 7 bytes



                                                                                                                  $%%.|.$


                                                                                                                  Try it online!



                                                                                                                  Ungolfed:



                                                                                                                   $ | $: Read an Integer
                                                                                                                  % % | %: Output it
                                                                                                                  . | .
                                                                                                                  $


                                                                                                                  Reversed:



                                                                                                                  $.|.%%$


                                                                                                                  Try it online!



                                                                                                                  Previous Version (8 bytes):



                                                                                                                  $.%..|.$





                                                                                                                  share|improve this answer












                                                                                                                  $endgroup$

















                                                                                                                    2















                                                                                                                    2











                                                                                                                    2







                                                                                                                    $begingroup$


                                                                                                                    Triangular, 8 7 bytes



                                                                                                                    $%%.|.$


                                                                                                                    Try it online!



                                                                                                                    Ungolfed:



                                                                                                                     $ | $: Read an Integer
                                                                                                                    % % | %: Output it
                                                                                                                    . | .
                                                                                                                    $


                                                                                                                    Reversed:



                                                                                                                    $.|.%%$


                                                                                                                    Try it online!



                                                                                                                    Previous Version (8 bytes):



                                                                                                                    $.%..|.$





                                                                                                                    share|improve this answer












                                                                                                                    $endgroup$




                                                                                                                    Triangular, 8 7 bytes



                                                                                                                    $%%.|.$


                                                                                                                    Try it online!



                                                                                                                    Ungolfed:



                                                                                                                     $ | $: Read an Integer
                                                                                                                    % % | %: Output it
                                                                                                                    . | .
                                                                                                                    $


                                                                                                                    Reversed:



                                                                                                                    $.|.%%$


                                                                                                                    Try it online!



                                                                                                                    Previous Version (8 bytes):



                                                                                                                    $.%..|.$






                                                                                                                    share|improve this answer















                                                                                                                    share|improve this answer




                                                                                                                    share|improve this answer








                                                                                                                    edited Oct 30 at 19:34

























                                                                                                                    answered Sep 17 at 19:40









                                                                                                                    Reinstate MonicaReinstate Monica

                                                                                                                    1,3212 silver badges12 bronze badges




                                                                                                                    1,3212 silver badges12 bronze badges























                                                                                                                        1 2
                                                                                                                        next

















                                                                                                                        draft saved

                                                                                                                        draft discarded















































                                                                                                                        If this is an answer to a challenge…



                                                                                                                        • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                        • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                          Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                        • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                                                                                        More generally…



                                                                                                                        • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                        • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                                                                                        draft saved


                                                                                                                        draft discarded














                                                                                                                        StackExchange.ready(
                                                                                                                        function ()
                                                                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f193021%2fi-reverse-the-source-code-you-negate-the-input%23new-answer', 'question_page');

                                                                                                                        );

                                                                                                                        Post as a guest















                                                                                                                        Required, but never shown





















































                                                                                                                        Required, but never shown














                                                                                                                        Required, but never shown












                                                                                                                        Required, but never shown







                                                                                                                        Required, but never shown

































                                                                                                                        Required, but never shown














                                                                                                                        Required, but never shown












                                                                                                                        Required, but never shown







                                                                                                                        Required, but never shown









                                                                                                                        Popular posts from this blog

                                                                                                                        Tamil (spriik) Luke uk diar | Nawigatjuun

                                                                                                                        Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                                                                                                        Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?