g | x | w | all
Bytes Lang Time Link
009AWK250804T133829Zxrs
023Bespoke250804T111335ZJosiah W
005Vyxal230508T234957Zemanresu
003J191109T032310ZJonah
003><> Fish230508T134210Zemirps
002Dis221018T131919Z鳴神裁四点一号
002Brachylog221018T114638ZFatalize
003Vyxal221018T113812ZDialFros
0177220626T110454Zais523
015Make220627T185130Zcnamejj
002Ly220627T072440Zcnamejj
001HBL220627T175118ZDLosc
nanFig 0.1.0220627T160311ZSeggan
106Python 3191109T101519Zuser2357
001Halfwit220627T061433Zemanresu
031Whispers v3210204T163513ZRazetime
002Actually201221T033445ZPkmnQ
00433201221T032414ZTheOnlyM
003AppleSoft Basic201220T235902Zroblogic
nan201220T202537ZKamila S
002@191125T052447Zuser8505
002GolfScript191125T035708Zuser8505
004Ahead191124T201123Zsnail_
014Java191111T225931ZOkx
2025Bitwise Cyclic Tag191114T034906Zuser8505
010SimpleTemplate191113T101219ZIsmael M
052Haskell191112T172728ZOpenAI w
004TIBASIC Nontrivial191111T200301ZFeldspar
012bash191110T013648ZFeldspar
020Whitespace191111T170623ZKevin Cr
002Deadfish~191111T165158Zsquid
013Poetic191111T162433ZJosiahRy
003Triangular191111T153156Zsquid
004SmileBASIC191111T142841Z12Me21
019JavaScript191109T013535Zrydwolf
003MarioLANG191111T091739ZCoedRhyf
012HolyC191110T192339ZRoninkoi
002Rebol191110T101624ZBent For
003POSIX sh Dash191110T100537ZGammaFun
002R191109T235415ZAkselA
003Runic Enchantments191110T012903ZDraco18s
019Turing Machine Code191109T155519Zouflak
010Wolfram Language Mathematica191109T202031Zatt
002Befunge98 PyFunge191109T185018ZThe Fift
021C gcc191109T183906ZS.S. Ann
002Jelly191108T232049Zhyperneu
002Actually191109T041402Zuser8505
002MathGolf191109T125942Zuser8505
032Wren191109T035800Zuser8505
020Ceylon Snippet191109T122832ZPaŭlo Eb
002PHP191109T111258ZNight2
002Japt191109T100831ZAZTECCO
006Ruby191109T103313ZNeil Sla
011Perl 5191109T073529ZXcali
002brainf***191109T061748ZHiddenBa
00205AB1E191109T035915Zuser8505
002Japt191109T032748ZGymhgy
002Pyth191108T233048Zfrank
017Python 3191108T233248Zhyperneu
002Keg191108T233040Zlyxal

AWK, 9 bytes

$0=1#2=0$

Attempt This Online!

Something more substantial:

AWK, 23 bytes

END{print(2^1)tnirp}DNE

Attempt This Online!

Works because AWK will assume tnirp and DNE are empty variables.

Bespoke, 23 bytes

Forwards

won O.K drawer-on a ram

Outputs ASCII 1 (SOH). Equivalent to PUT X:I;OUTPUT CH;H LDV.

Backwards

mar a no-reward K.O now

Outputs the number 2. Equivalent to PUT X:BI;OUTPUT N;H LDV.

Vyxal, 4 bits1, 0.5 bytes

2

Try it Online! (link is to bitstring) The bitstring form of this is 0101, which translates to 2.

Reversed - Try it Online! (outputs 0)

If we stretch the rules a bit, we can get two bits: Try it Online! !enilnO ti yrT, which respectively output an empty string and 0 - 0 and 1 in unary.

J, 3 bytes

1"_

Try it online!

one or infinity...

><> (Fish), 3 bytes

0n1

Try it forwards

Try it backwards 1n0

Dis, 2 bytes

{!

Try on dis.web! Outputs one NULL character.

!bew.sid no yrT Outputs nothing.

Brachylog, 2 bytes

+1

Try it online!

There are probably loads of different 2 byte answers.

Explanation

+1 states that 1 is the result of the sum of an unknown list of integers, which is obviously true. (there are infinitely such lists).

1+ states that we can sum the list 1 into some result, which is obviously false. since 1 isn’t a list.

Vyxal, 3 bytes

2-1

Try it Online!

Running it forward gives 1, running it backwards gives 2.

This because vyxal's syntax is weird:

ab- (vyxal) = a-b (py)

7, 2 characters, 1 byte in 7's encoding

31

Try it online! (forwards)

Try it online! (reversed)

This should be the first valid 1-byte solution (because the existing 1-byte solution in BCT requires a particular value on its input to work, and isn't counting it in the byte count – that could only be assumed in a full program, and BCT full programs can't do I/O and must wipe all their working memory to be able to halt, thus have no way to halt with a value). 7's encoding packs multiple characters into a single byte: here are xxd hexdumps for the forward and reverse programs:

00000000: 67                                       g
00000000: 2f                                       /

This conceptually outputs a string: 31 for the forwards program, and an empty string for the backwards program. The output encoding is set to be the same as the input encoding; so if you encode the program in 7's encoding, you'll get a single byte of output which encodes the string 31 (and if you use ASCII instead, you'll get two bytes that encode the string 31 in ASCII).

Explanation

On the first pass through the program, the 3 appends a "print and pop" command to the stack, and the 1 appends a "push empty stack element" command to the stack. So, we end up forming a program on top of the stack. At the end of the first pass through the program, 7 will run the resulting program, but without popping it from the stack.

With the forward version of the program, the "print and pop" command will attempt to print the program consisting of a "print" command and a "pop" command. That isn't a valid literal, so the 7 interpreter will construct code that's capable of constructing that stack element and print that instead; in this case, the code it finds for for "push a stack element that generates a 'print and pop' command then a 'push empty stack element command'" is 731 (i.e. basically the program we wrote, although our program appends to an implicit empty stack element, whereas the reconstructed program makes a new one). The print routine interprets the 7 as a command to set the output encoding to the same encoding that was used for the source code, and then the 31 is interpreted as a literal and gets printed. The command in question pops two things in total (the thing it's printing and the element below), so the stack now contains no data and thus there are no more passes through the program; it just exits (even though we push an empty stack element after this point, those don't affect the end-of-program behaviour).

With the reverse program, we're pushing the empty stack element before the print attempt, rather than the other way round, so it's now an empty string that gets printed, and the remnants of the program (which are below it) get popped without printing them. Everything is now the same as in the forward program, so the reverse program also exits naturally and without error.

Make, 14 15 bytes

x:#
	#$@$#	
#:y

Try it online!

Updated to add a trailing tab on the second line...

Here's another one that's not as short, but seems interesting enough to post...

Forwards it prints x and backwards it prints y. It works by referencing the $@ symbol, which is defined as the target being made. The "command" run is just a comment to the shell, so it's a no-op. But by default Make echos the commands it runs.

Also, the $# reference doesn't cause an error, and evaluates to an empty string, which allows #$@$# to work both directions without having to add more characters.

Ly, 2 bytes

-`

Try it online!

Forwards outputs 1 and backwards shows -1.

Why? Forwards:

 -   : subtract top two stack entries, when empty produces "0" 
  `  : increment top of stack, produces "1"

Backwards:

`   : increment top of stack, when empty produces "0"
 -  : subtract top two stack entries, produces "-1"

HBL, 1 byte

+2

Run forwards, outputs 3:

+   Increment
 2  Two

Run backwards, outputs 8:

2   Double
 +  Four

In fact, any program consisting of two characters from the set 2<+-/% will work. Here are all the possible combinations together with their outputs. We could also add 0 to the set if it weren't for the "same data type" restriction.

Fig 0.1.0, \$2\log_{256}(96)\approx\$ 1.646 bytes

,"

See the README to see how to run this

Argh. Beaten by Halfwit by more than half a byte. In the forward position, it prints a single newline. Backwards, ",, it prints a comma followed by a newline.

Python 3, no comments or string literals, 106 bytes

x=quit
y=x.__class__
y.__add__=print
y.__pos__=x
x+x++x+x
x=__sop__.y
tnirp=__dda__.y
__ssalc__.x=y
tixe=x

I've never liked how comments and string literals let you "turn off" most of your language's syntax in challenges like this, so I wanted to see how far I could golf things without using either comments or string literals. This is what I came up with.

Since I don't have any way to disable the syntactical significance of parentheses, I cannot use the function call operator. Any attempt to do so would result in the reversed code having a closing parenthesis before the first opening parenthesis, which is invalid outside a comment or string literal. I also can't use def or container literals (aside from unparenthesized tuples), and my access to language features is in general extremely restricted.

One thing I can do is take advantage of Python's operator overloading to call functions implicitly. My ability to define any classes or functions is extremely limited, but fortunately, there are enough tools lying around in the built-in namespace for me to use. Most built-ins don't let me perform the attribute assignment I need to redefine their operator overloads, but (unless Python is run with one of the flags that disables site importing) the auto-imported site module adds quit and exit objects to the built-ins. These objects are instances of non-C classes, so I can reassign their operator overloads.

Setting __add__ to print lets me use addition to print things, and setting __pos__ to quit or exit lets me use the unary + operator to abort the program before the rest of the code runs. Without setting __pos__, I would need a bunch of additional code to make sure the "backwards" part of the code can find all the variables and attributes it needs to not fail. With __pos__, I only need to make sure the "backwards" code is still syntactically valid.

Forward, the code prints

Use quit() or Ctrl-D (i.e. EOF) to exit

Backward, the code prints

Use exit() or Ctrl-D (i.e. EOF) to exit

(The messages are slightly different on Windows. For platform-independent output at the expense of 3 extra bytes, you can replace the middle line with x+1++x++2+x, printing 1 when run forwards and 2 when run backwards.)


I also tried to figure out a way to do this by defining my own class instead of messing with quit.__class__. I got as far as the following:

if.1j:adbmal=1j
class ton:adbmal
a=lambda:j1.fi
j1=a
a.__dict__=a.__globals__

class ton:adbmal is one of the very few combinations of class name and class body such that the class statement is syntactically valid backward. tressa, led, labolg, tropmi, and esiar would also have been valid class names (with a different class body, such as not fi), but ton is the only one where the reversed name can be part of an expression, giving the most flexibility.

if.1j:adbmal=1j assigns a value to adbmal to make the class body succeed, while still being syntactically valid backward.

The stuff with a and j1 lets me use j1.ton to refer to my ton class, which is still a valid expression backward.

At this point, I got stuck. I couldn't figure out how to get my class out of j1.ton and into a more useful variable. I can't assign attributes on j1.ton and still have valid syntax backward, so I can't set operator overloads. I also wanted to set builtins.__build_class__ to my class so I could abuse the class statement to construct instances without the function call operator, but trying to put j1.ton on the right side of an assignment produces invalid syntax backward.

If I had been able to name my class something like fi or tpecxe, I could have used tricks like b:j1.fi to get the class into an annotation and then a.__dict__=__annotations__ to get it into a.b, but I couldn't find any way to get the class statement and the annotation tricks to hook up. Anything that was compatible with the class statement was incompatible with the annotation tricks.

(You might wonder why I didn't abuse builtins.__build_class__ to call an existing function directly, like print. I couldn't figure out a way to do that and have the output be deterministic, and I wanted deterministic output.)

Halfwit, 1 byte

*k

Try It Online!

The second valid one-byte solution :P

* is multiplication, multiplying two 0s. k is a digraph character, and on its own a NOP, but k* is exponentiation.

Alternatively, anything that's a single char before > works as > delimits a compressed integer, so >x will push some number, and x> will apply x then push 0.

Whispers v3, 31 bytes

1 tuptuO >>
> 1
>> Output 1
0 >

Try it online!, !enilnO tI yrT

Hooray for strict parsing rules!

The first and last lines are ignored, because they don't fit the right syntax. They come into action when reversed.

Actually, 2 bytes

12

Try it online!

Prints 2\n1\n forwards, and 1\n2\n backwards.

33, 4 bytes

o1ao

Try it online!

Outputs 01 if run forwards or 00 if run backward

AppleSoft Basic, 3 bytes

0?1 outputs 1
1?0 outputs 0

0?"?1 <=> 1?"?0

verified here

Dyalog APL

Boring solution using comments

0⍝1   => 0
1⍝0   => 1

Even more boring numeric solution:

10    => 10
01    => 1

Basic arithmetics:

2-1    => 1
1-2    => ¯1

@, 2 bytes

Outputs \n1, where \n represents a literal newline.

\1

Reversed

Returns 1, the expression after 1 is ignored.

1\

Try it online!

GolfScript, 2 bytes

Simply prints 1 because the duplicate instruction duplicates the null string.

.1

Reversed

Outputs 11 because that is the value 1 duplicated.

1.

Try it online!

GolfScript, 4 bytes

Outputs 0 because 1 - 1 is 0.

1 1-

Reversed

Outputs -11 due to concatenation.

-1 1

Try it online!

GolfScript, 2 bytes (Am I allowed to use the null string?)

Outputs the null string, because the null string from the input minus 1 is still the null string.

1-

Reversed:

Pushes -1 onto the stack.

-1

Try it online!

Ahead, 4 bytes

O@j1

Prints 0 forward and 1 backward.

Forward

O     pop stack and print number
 @    end
  j1  not reached

Backward

1     push 1
 j    jump next cell
   O  pop stack and print number
  @   end

Control flow is more interesting backward because I tried to reduce the amount of redundant characters.

Try it online!

Java, 14 bytes

()->1;//;0>-)(

Simple function that uses comments to exclude the other part. Outputs 1, and reversed outputs 0.

Bitwise Cyclic Tag, 2 bits (0.25 bytes)

With an input of 1 this should either set the data string to a null string or a string of length 2 in its next iteration.

01

Explanation:

0  Delete the leftmost data bit.
   Halt. No more instructions executed.
 1 Not executed

Reversed:

1  If the left-most data-bit is 1,
 0 Append a 0 to the data-string.

SimpleTemplate, 10 bytes

This was actually hard to optimize, without going into the trivial answer.

{@echo"1"}

Outputs the string "1".

When reversing, you get the following:

}"1"ohce@{

Outputs the string }"1"ohce@{.

As stated in the question: "The output can be any two distinct values, of the same data type.", and both solutions output a distinct string.

You can test this on http://sandbox.onlinephpfunctions.com/code/ec4bf4b3efa93c63c6c5c9f1458330da0178b6cd
(On line 960, change between the $code and $reversed variables)



SimpleTemplate, 2 bytes

This one is extremelly trivial:

<any 2 different bytes>

Reversing them will output whatever is reversed.

Haskell, 52 bytes

a=0--
--b tnirp=b#a
niam=main
1#a=niam
main=print a

==> prints "1"

a tnirp=niam
main=a#1
niam=main
a#b=print b--
--0=a

==> prints "0"

Explanation:

a=0--
-- FWD: define constant "a" to be 0 / BWD: No-op                                 --

--b tnirp=b#a
-- FWD: No-op / BWD: define a function "#" in two arguments and prints the       --
-- second                                                                        --

niam=main
-- FWD & BWD: define constant "niam" to be the same as "main"                    --

1#a=niam
-- FWD: define a function "#" in two arguments that produces "main" if the first --
-- argument is 1 / BWD: define constant "main" to be the result of the function  --
-- "#" applied to the arguments "a" and 1                                        --

main=print a
-- FWD: define constant "main" to be an IO action that prints the value of "a" / --
-- BWD: define a function "a" in one argument that always produces the value     --
-- of "niam"                                                                     --

Of course, there is also the shorter item:

Haskell, 29 bytes

main=print 1--
--0 tnirp=niam

which is much less interesting.

TI-BASIC Non-trivial, 4 5 bytes

Disp "Disp :

This outputs 'Disp :'

Since TI-BASIC is token based, reversing it gives

:Disp "Disp

which outputs 'Disp'

Let me explain. 'Disp ' is one token which prints the given string to the home screen. First we are giving it a string of 'Disp :', so simple there. When reversed, since each 'Disp ' is one byte, we get the reversed code above. This reversed code starts with a ':', which ends the line, and means nothing here. The remaining code is 'Disp "Disp ', which runs and outputs 'Disp ' to the home screen.

TI-BASIC Trivial, 2 bytes

If a program ends with a values, then it outputs it. This lets us do

12

which outputs 12, and reversed is

21

which outputs 21.

bash, 12 bytes (no comments or string literals)

echo 0$ ohce

Prints "0$ ohce"

echo $0 ohce

Prints "bash ohce"

bash, 11 bytes (no comments or string literals)

echo ftnirp

Prints "ftnirp"

printf ohce

Prints "ohce"

Whitespace, 20 bytes

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

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

Outputs 0/-1.

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

Explanation:

Very minor modification of my answer here (outputting 0 is 1 byte shorter than 1), so I'm just gonna copy-paste the explanation:

Utilizing the Exit Program builtin being a short palindrome NNN (also note that without an exit, every Whitespace program would result in an error, making it invalid for this challenge).
The regular program will:

SSSN   # Push 0 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:

SSTTN  # Push -1 to the stack
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:

I.e. SSTTSTSN pushes -10. Only the first three and trailing N are mandatory, so SSSN/SSTN will both push 0.

Deadfish~, 2 bytes

oi

Try it online!

Boy, if that fruit hanged any lower, it'd be underground I tell you.

Poetic, 15 13 bytes

tis,A NAMETAG

Try it online!

Prints ASCII character 1 (SOH).

GATEMAN A,sit

Try it online!

Prints ASCII character 0 (NUL).

The previous answer ends with an "Unexpected EOF" error forwards because the END command (any ten-letter word) is omitted, and a "Mismatched IF/EIF" error backwards because EOF is encountered before an IF/EIF loop can end. The following answer terminates properly.

Poetic, 51 bytes

the difference between I and certain ridiculous men

Try it online!

Prints a newline.

nem suolucidir niatrec dna I neewteb ecnereffid eht

Try it online!

Prints a newline and a "vertical tab" character.

(I really wanted to be able to make the programs make sense both backwards and forwards, but I'm not sure that's possible in English, and I don't know any other languages to try that out with.)

Triangular, 3 bytes

i.%

Try it online!

Prints 1.

%.i prints 0.

If it weren't invalid to do an integer and a character, %# would've been a nice 2-byter.

SmileBASIC, 4 bytes

?12?

prints 12\n\n forwards and 21\n\n backwards

JavaScript, 19 bytes

Returns true because of the assignment at the end, since JS treats that as defining a global variable. The first part is an arrow function, which is ignored. When run backwards, eurt is set to NaN (not a number), and since NaN is not greater than true (or equal), it returns false.

eurt=>true;NaN=true

Try it online!

eurt=NaN;eurt>=true

Try it online!

JavaScript, 3 bytes

A snippet which outputs 1, or -1 in reverse. Very simple.

2-1

Try it online!

1-2

Try it online!

JavaScript, 7 bytes

Abuses the not equal to operator and the not operator, will output false, or true in reverse. JavaScript uses NaN as not-a-number.

5==!NaN

Try it online!

NaN!==5

Try it online!

JavaScript, 18 bytes

Another boring solution, with comments instead of subtraction. Returns 1, or 2 in reverse. I included the print statements in these.

print(1)//)2(tnirp

Try it online!

print(2)//)1(tnirp

Try it online!

JavaScript, 7 bytes

Similar to the previous answer, but with assignment instead of equal-to. Uses the atob variable, which is a builtin in browser Javascript (decodes base64). Since TIO doesn't include browser builtins, I defined it just to keep it from erroring. Works as expected in console. Return true, or false in reverse.

2!=atob

Try it online!

bota=!2

Try it online!

MarioLANG, 3 bytes

:
+

Try it online!

Prints 0

+
:

Try it online!

Prints 1


MarioLANG, 10 bytes

 ==
:+
== 

Try it online!

Prints 0

 ==
+:
== 

Try it online!

Prints 1

HolyC, 12 bytes

Like the C version, except using the implicit print in HolyC

"0"; // ;"1"

Prints 0

"1"; // ;"0"

Prints 1

Spaces required by the compiler :)

Rebol, 2 bytes

#1

Prints #1

1#

Prints ##

POSIX sh (Dash, Bash, Zsh, ...), 3 bytes

: !

Try it online!

The builtin : discards its arguments and exits 0 (true). Reversed, ! negates the exit code of : and exits 1 (false).

R, 2 bytes

.1

Prints 0.1.

1.

Prints 1.

Both numeric (double).

tio

Less trivial? and for an explicit true/false

2>1
# TRUE

1>2
# FALSE

tio

Runic Enchantments, 3 bytes

0@1

Try it online!

Prints 0 forwards and 1 backwards.

If no output is allowed, then @1 saves a byte.

Turing Machine Code, no comments or string literals, 19 bytes

0 * 0 * 0
0 * 1 * 0

Reversed:

0 * 1 * 0
0 * 0 * 0

Try it online!

The code runs without errors, but does loop forever. Prints '0' forward, prints '1' reversed.

Wolfram Language (Mathematica), 10 bytes

Print@ohcE

Try it online!

Prints ohcE.

Echo@tnirP

Try it online!

Prints >> tnirP.

Befunge-98 (PyFunge), 2 bytes

@,

Try it online!

Prints nothing by default, prints a null byte if reversed

C (gcc), 21 bytes

puts("");//;)"0"(stup

Try it online!

!enilno ti yrT

Jelly, 2 bytes

+1

Try it online!

Prints 1.

Jelly, 2 bytes

1+

Try it online!

Prints 2.

The reason for this is that Jelly's dyad-nilad structure chains differently on either side. +1 becomes a monad meaning "plus one", which is applied to the Left Argument, which defaults to zero. 1+ does not become a monadic chain here (if I remember correctly - correct me if my Jelly theory is off; I'm a bit rusty on the structural component), but rather is seen as 1 set as the Left Argument, and then + is applied as a dyad to (left, left) in the default case of no Right Argument, giving 1 + 1.

Great challenge; I almost feel like this is a cheese. I don't know if I should be happy with this solution or feel bad for having such a short and trivial solution >_<.

This uses Jelly's structure to be fancy. A more boring answer would just be 01 (prints 1) and 10 (prints 10), or any other two-digit number and its reverse (that isn't a palindrome).

Actually, 2 bytes

Decrement empty value & push 1.

D1

Reversed program decrements 1, outputting 0.

1D

Try it online!

05AB1E, 2 bytes

The exact same answer ported to a different language.

<1

Try it online!

MathGolf, 2 bytes

This one does not have any nilads or dyads inside the program. Just monads.

±(

Try it online!

Explanation

±  Find absolute value of the implicit 0
 ( Decrement 0, resulting -1.

Reversed:

(  Decrement 0, resulting -1.
 ± Find absolute value of -1, which results in 1.

Wren, 32 bytes

Basically just a port of the Python answer.

System.write(1)//)0(etirw.metsyS

Try it online!

Ceylon (Snippet), 20

The same trivial thing as in many other languages:

print(1);//;)2(tnirp

Outputs 1.

print(2);//;)1(tnirp

Outputs 2.

Given that parentheses need to be in the right order and you need print for output, I don't think this can be improved.

A full program or function needs even more braces/parentheses mirrored, so no chance of getting it better.

Ceylon (anonymous function), 17

If we don't need to output anything, but just return it from an anonymous function, then this is enough:

()=>//
1.2
//>=)(

A function which returns 1.2 (a floating point value).

()=>//
2.1
//>=)(

A function which returns 2.1 (a floating point value).

Ceylon (expression with return value), 3

If we accept just an expression (which then can be printed), then we don't even need any comments:

2.1

Gives 2.1 (a floating point value).

1.2

Gives 1.2 (a floating point value).

Try all of them online

PHP, 2 bytes

12

Try it online!

Prints 12 ...

21

Try it online!

Prints 21 ...


Looking for non-trivial solution?

PHP, 11 bytes

<?=1;#;2=?<

Try it online!

Prints 1 ...

<?=2;#;1=?<

Try it online!

Prints 2 ...


Don't like comment abuse?

PHP, 13 bytes

;echo+1-ohce;

Try it online!

Prints 1 ...

;echo-1+ohce;

Try it online!

Prints -1 ...

Note: this one is an exact copy of my answer here: https://codegolf.stackexchange.com/a/193169

Japt, 2 bytes

c1

Return x rounded up to nearest multiple of N => output 0

Test it

1c

x default to 1 => output 1

Test it

Ruby, 6 bytes

p:stup

Output

:stup

Reversed output

p

Perl 5, 11 bytes

say$-,$$yas

Try it online!

Outputs 0 when run forward. Outputs the current process number followed by 0 when run backwards.

brainf*** 2 bytes

+.

Try it online!

Outputs 1 forwards, 0 backwards. Really randomdude999's answer

05AB1E, 2 bytes

Push 1 onto the stack & negates. (This results in -1)

1(

Negate empty value & push 1. Output 1 implicitly.

(1

Try it online!

Japt, 2 bytes

1g

Returns 1. Reverse returns -1.

g is the sign function when it has no arguments, and returns the sign of the argument minus the caller if called with an argument. So g1 would be the sign of zero minus one because the default input is 0

Test it

Pyth, 2 bytes

\"

Try it online!

Returns the string ' " ' (one set of double quotes)

Pyth, 2 bytes

"\

Try it online!

Returns "\"

Oops, my earlier answer missed that they had to be the same data type. This answer returns two different strings, and relies on the fact that '\' makes a one character string of the input and that Pyth closes strings implicitly

Python 3, 17 bytes

print(1)#)2(tnirp

Try it online!

I promise this is the last trivial/cheese one I post; I'm trying to think of a more interesting solution. If I remember I'll see where I can get with this.

Keg, 2 bytes

10

Try it online!

Keg, 2 bytes

01

Try it online!

When run forwards, it prints 10. When run backwards, it prints 01.

I might try to create a non-trivial answer soon, as this seems like a really great challenge!