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!Character counts in source codeSource Code MetamorphosisQuine / Reverse QuineDouble-duty quine: quine!dlroW ,olleHInput ∩ Source CodeSource 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!
Audire, with accusative or dative?
Should the pagination be reset when changing the order?
The relationship of noch nicht and the passive voice
What are sources for Magic Items that are not adventure-specific?
What was the deeper meaning of Hermione wanting the cloak?
All numbers in a 5x5 Minesweeper grid
How often is duct tape used during crewed space missions?
Is there any actual security benefit to restricting foreign IPs?
Why would a fighter use the afterburner and air brakes at the same time?
I feel like most of my characters are the same, what can I do?
Delete empty subfolders, keep parent folder
What are the end bytes of *.docx file format
Can I separate garlic into cloves for storage?
Applications of mathematics in clinical setting
Lead Amalgam as a Material for a Sword
Removing rows containing NA in every column
Why is the stock market so unpredictable?
Find all files in directories named foo
Microservices and Stored Procedures
What is the word for a person who destroys monuments?
Should I inform my future product owner that there is a good chance that a team member will leave the company soon?
How to influence manager to not schedule team meetings during lunch?
What do solvers like Gurobi and CPLEX do when they run into hard instances of MIP
How does one calculate the distribution of the Matt Colville way of rolling stats?
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!Character counts in source codeSource Code MetamorphosisQuine / Reverse QuineDouble-duty quine: quine!dlroW ,olleHInput ∩ Source CodeSource 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!
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$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
.
code-golf math number source-layout
$endgroup$
add a comment
|
$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
.
code-golf math number source-layout
$endgroup$
add a comment
|
$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
.
code-golf math number source-layout
$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
code-golf math number source-layout
asked 8 hours ago
AdámAdám
29.8k2 gold badges82 silver badges214 bronze badges
29.8k2 gold badges82 silver badges214 bronze badges
add a comment
|
add a comment
|
20 Answers
20
active
oldest
votes
$begingroup$
Brain-Flak, 7 bytes
#)]}improve this answer
$endgroup$
add a comment
$begingroup$
Brain-Flak, 7 bytes
#)][(
Try it online!
Reversed:
([])#
Try it online!
$endgroup$
Brain-Flak, 7 bytes
#)]{[(
Try it online!
Reversed:
([])#
Try it online!
answered 5 hours ago
RileyRiley
11.2k1 gold badge16 silver badges48 bronze badges
11.2k1 gold badge16 silver badges48 bronze badges
add a comment
|
add a comment
|
$begingroup$
Gaia, 2 bytes
_@
Try it online!
_ | implicit push input and negate
@ | push input
| implicit print TOS
Reversed:
@ | push input
_ | negate
| implicit print TOS
$endgroup$
add a comment
|
$begingroup$
Gaia, 2 bytes
_@
Try it online!
_ | implicit push input and negate
@ | push input
| implicit print TOS
Reversed:
@ | push input
_ | negate
| implicit print TOS
$endgroup$
add a comment
|
$begingroup$
Gaia, 2 bytes
_@
Try it online!
_ | implicit push input and negate
@ | push input
| implicit print TOS
Reversed:
@ | push input
_ | negate
| implicit print TOS
$endgroup$
Gaia, 2 bytes
_@
Try it online!
_ | implicit push input and negate
@ | push input
| implicit print TOS
Reversed:
@ | push input
_ | negate
| implicit print TOS
answered 8 hours ago
GiuseppeGiuseppe
19.3k3 gold badges16 silver badges71 bronze badges
19.3k3 gold badges16 silver badges71 bronze badges
add a comment
|
add a comment
|
$begingroup$
PowerShell, 18 14 bytes
$args#"sgra$"-
Try it online! !enilno ti yrT
First of the trivial comment-abuse answers
$endgroup$
1
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
add a comment
|
$begingroup$
PowerShell, 18 14 bytes
$args#"sgra$"-
Try it online! !enilno ti yrT
First of the trivial comment-abuse answers
$endgroup$
1
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
add a comment
|
$begingroup$
PowerShell, 18 14 bytes
$args#"sgra$"-
Try it online! !enilno ti yrT
First of the trivial comment-abuse answers
$endgroup$
PowerShell, 18 14 bytes
$args#"sgra$"-
Try it online! !enilno ti yrT
First of the trivial comment-abuse answers
edited 7 hours ago
answered 8 hours ago
VeskahVeskah
2,2575 silver badges24 bronze badges
2,2575 silver badges24 bronze badges
1
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
add a comment
|
1
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
1
1
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
$begingroup$
Oh, God. Not this again.
$endgroup$
– JL2210
7 hours ago
add a comment
|
$begingroup$
05AB1E, 2 bytes
(I
Try it online!
Reversed
( negates nothing
I pushes input
I pushes input
( negates input
New contributor
$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
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
add a comment
|
$begingroup$
05AB1E, 2 bytes
(I
Try it online!
Reversed
( negates nothing
I pushes input
I pushes input
( negates input
New contributor
$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
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
add a comment
|
$begingroup$
05AB1E, 2 bytes
(I
Try it online!
Reversed
( negates nothing
I pushes input
I pushes input
( negates input
New contributor
$endgroup$
05AB1E, 2 bytes
(I
Try it online!
Reversed
( negates nothing
I pushes input
I pushes input
( negates input
New contributor
edited 7 hours ago
New contributor
answered 7 hours ago
jasanbornjasanborn
114 bronze badges
114 bronze badges
New contributor
New contributor
$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
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
add a comment
|
$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
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
$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
7 hours ago
$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
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
$begingroup$
My bad, I misunderstood
$endgroup$
– jasanborn
7 hours ago
add a comment
|
$begingroup$
Jelly, 2 bytes
oN
Try it online! and its reverse.
oN - (input) OR ((input) negated)
No - ((input) negated) OR (input)
$endgroup$
$begingroup$
Heh, you can also doḷN
, no need for the OR logic. :D
$endgroup$
– Erik the Outgolfer
5 hours ago
1
$begingroup$
Na
, words giveaN
aesthetic effect :)
$endgroup$
– Jonathan Allan
5 hours ago
add a comment
|
$begingroup$
Jelly, 2 bytes
oN
Try it online! and its reverse.
oN - (input) OR ((input) negated)
No - ((input) negated) OR (input)
$endgroup$
$begingroup$
Heh, you can also doḷN
, no need for the OR logic. :D
$endgroup$
– Erik the Outgolfer
5 hours ago
1
$begingroup$
Na
, words giveaN
aesthetic effect :)
$endgroup$
– Jonathan Allan
5 hours ago
add a comment
|
$begingroup$
Jelly, 2 bytes
oN
Try it online! and its reverse.
oN - (input) OR ((input) negated)
No - ((input) negated) OR (input)
$endgroup$
Jelly, 2 bytes
oN
Try it online! and its reverse.
oN - (input) OR ((input) negated)
No - ((input) negated) OR (input)
answered 7 hours ago
Jonathan AllanJonathan Allan
60.3k5 gold badges44 silver badges187 bronze badges
60.3k5 gold badges44 silver badges187 bronze badges
$begingroup$
Heh, you can also doḷN
, no need for the OR logic. :D
$endgroup$
– Erik the Outgolfer
5 hours ago
1
$begingroup$
Na
, words giveaN
aesthetic effect :)
$endgroup$
– Jonathan Allan
5 hours ago
add a comment
|
$begingroup$
Heh, you can also doḷN
, no need for the OR logic. :D
$endgroup$
– Erik the Outgolfer
5 hours ago
1
$begingroup$
Na
, words giveaN
aesthetic effect :)
$endgroup$
– Jonathan Allan
5 hours ago
$begingroup$
Heh, you can also do
ḷN
, no need for the OR logic. :D$endgroup$
– Erik the Outgolfer
5 hours ago
$begingroup$
Heh, you can also do
ḷN
, no need for the OR logic. :D$endgroup$
– Erik the Outgolfer
5 hours ago
1
1
$begingroup$
Na
, words give aN
aesthetic effect :)$endgroup$
– Jonathan Allan
5 hours ago
$begingroup$
Na
, words give aN
aesthetic effect :)$endgroup$
– Jonathan Allan
5 hours ago
add a comment
|
$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
$endgroup$
add a comment
|
$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
$endgroup$
add a comment
|
$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
$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
edited 6 hours ago
answered 6 hours ago
Jonathan AllanJonathan Allan
60.3k5 gold badges44 silver badges187 bronze badges
60.3k5 gold badges44 silver badges187 bronze badges
add a comment
|
add a comment
|
$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
.
$endgroup$
add a comment
|
$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
.
$endgroup$
add a comment
|
$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
.
$endgroup$
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
.
answered 5 hours ago
guifaguifa
7033 silver badges10 bronze badges
7033 silver badges10 bronze badges
add a comment
|
add a comment
|
$begingroup$
Klein, 2 bytes
Works in all 12 topologies!
@-
Try it online!
Reverse
-@
Try it online!
-
negates the input and @
ends the program
$endgroup$
add a comment
|
$begingroup$
Klein, 2 bytes
Works in all 12 topologies!
@-
Try it online!
Reverse
-@
Try it online!
-
negates the input and @
ends the program
$endgroup$
add a comment
|
$begingroup$
Klein, 2 bytes
Works in all 12 topologies!
@-
Try it online!
Reverse
-@
Try it online!
-
negates the input and @
ends the program
$endgroup$
Klein, 2 bytes
Works in all 12 topologies!
@-
Try it online!
Reverse
-@
Try it online!
-
negates the input and @
ends the program
edited 2 hours ago
answered 6 hours ago
Sriotchilism O'ZaicSriotchilism O'Zaic
37.9k10 gold badges169 silver badges383 bronze badges
37.9k10 gold badges169 silver badges383 bronze badges
add a comment
|
add a comment
|
$begingroup$
J, 3 bytes
-&0
Try it online!
-&0
is "argument minus 0"
0&-
is "0 minus argument"
$endgroup$
1
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
add a comment
|
$begingroup$
J, 3 bytes
-&0
Try it online!
-&0
is "argument minus 0"
0&-
is "0 minus argument"
$endgroup$
1
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
add a comment
|
$begingroup$
J, 3 bytes
-&0
Try it online!
-&0
is "argument minus 0"
0&-
is "0 minus argument"
$endgroup$
J, 3 bytes
-&0
Try it online!
-&0
is "argument minus 0"
0&-
is "0 minus argument"
answered 1 hour ago
JonahJonah
4,8022 gold badges12 silver badges22 bronze badges
4,8022 gold badges12 silver badges22 bronze badges
1
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
add a comment
|
1
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
1
1
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
$begingroup$
this is really quite nice :)
$endgroup$
– Conor O'Brien
48 mins ago
add a comment
|
$begingroup$
Triangular, 8 bytes
$.%..|.$
Try it online!
Ungolfed:
$ Read an integer
. % Output it
. . | Negate (doesn't matter here)
. $
Reversed:
$.|..%.$
Try it online!
$endgroup$
add a comment
|
$begingroup$
Triangular, 8 bytes
$.%..|.$
Try it online!
Ungolfed:
$ Read an integer
. % Output it
. . | Negate (doesn't matter here)
. $
Reversed:
$.|..%.$
Try it online!
$endgroup$
add a comment
|
$begingroup$
Triangular, 8 bytes
$.%..|.$
Try it online!
Ungolfed:
$ Read an integer
. % Output it
. . | Negate (doesn't matter here)
. $
Reversed:
$.|..%.$
Try it online!
$endgroup$
Triangular, 8 bytes
$.%..|.$
Try it online!
Ungolfed:
$ Read an integer
. % Output it
. . | Negate (doesn't matter here)
. $
Reversed:
$.|..%.$
Try it online!
answered 8 hours ago
squidsquid
1,0711 silver badge10 bronze badges
1,0711 silver badge10 bronze badges
add a comment
|
add a comment
|
$begingroup$
Japt, 3 bytes
TnU
Try it | Reversed
Same method as my earlier solution, with T
being 0
and U
being the input.
$endgroup$
add a comment
|
$begingroup$
Japt, 3 bytes
TnU
Try it | Reversed
Same method as my earlier solution, with T
being 0
and U
being the input.
$endgroup$
add a comment
|
$begingroup$
Japt, 3 bytes
TnU
Try it | Reversed
Same method as my earlier solution, with T
being 0
and U
being the input.
$endgroup$
Japt, 3 bytes
TnU
Try it | Reversed
Same method as my earlier solution, with T
being 0
and U
being the input.
answered 8 hours ago
ShaggyShaggy
21.6k3 gold badges21 silver badges72 bronze badges
21.6k3 gold badges21 silver badges72 bronze badges
add a comment
|
add a comment
|
$begingroup$
V (vim), 5 bytes
É-ó--
Try it online!
Hexdump:
00000000: c92d f32d 2d .-.--
$endgroup$
add a comment
|
$begingroup$
V (vim), 5 bytes
É-ó--
Try it online!
Hexdump:
00000000: c92d f32d 2d .-.--
$endgroup$
add a comment
|
$begingroup$
V (vim), 5 bytes
É-ó--
Try it online!
Hexdump:
00000000: c92d f32d 2d .-.--
$endgroup$
V (vim), 5 bytes
É-ó--
Try it online!
Hexdump:
00000000: c92d f32d 2d .-.--
answered 8 hours ago
DJMcMayhem♦DJMcMayhem
42.3k12 gold badges160 silver badges330 bronze badges
42.3k12 gold badges160 silver badges330 bronze badges
add a comment
|
add a comment
|
$begingroup$
APL (Dyalog Unicode), 13 bytes
(⊢-∘0)⍝)⊢-∘0(
Try it online!
Trivial answer. Returns arg-0
or 0-arg
.
$endgroup$
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
add a comment
|
$begingroup$
APL (Dyalog Unicode), 13 bytes
(⊢-∘0)⍝)⊢-∘0(
Try it online!
Trivial answer. Returns arg-0
or 0-arg
.
$endgroup$
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
add a comment
|
$begingroup$
APL (Dyalog Unicode), 13 bytes
(⊢-∘0)⍝)⊢-∘0(
Try it online!
Trivial answer. Returns arg-0
or 0-arg
.
$endgroup$
APL (Dyalog Unicode), 13 bytes
(⊢-∘0)⍝)⊢-∘0(
Try it online!
Trivial answer. Returns arg-0
or 0-arg
.
answered 7 hours ago
J. SalléJ. Sallé
2,5984 silver badges24 bronze badges
2,5984 silver badges24 bronze badges
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
add a comment
|
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
$begingroup$
Whoa, this can be done trivially in three bytes!
$endgroup$
– Adám
7 hours ago
add a comment
|
$begingroup$
JavaScript, 11 bytes
n=>n//n->=n
Try it Online! | Reversed
$endgroup$
add a comment
|
$begingroup$
JavaScript, 11 bytes
n=>n//n->=n
Try it Online! | Reversed
$endgroup$
add a comment
|
$begingroup$
JavaScript, 11 bytes
n=>n//n->=n
Try it Online! | Reversed
$endgroup$
JavaScript, 11 bytes
n=>n//n->=n
Try it Online! | Reversed
answered 7 hours ago
ShaggyShaggy
21.6k3 gold badges21 silver badges72 bronze badges
21.6k3 gold badges21 silver badges72 bronze badges
add a comment
|
add a comment
|
$begingroup$
C++ (gcc), 29 bytes
Function-like macro:
#define f(x)-x//x)x(g enifed#
Try it online!
$endgroup$
add a comment
|
$begingroup$
C++ (gcc), 29 bytes
Function-like macro:
#define f(x)-x//x)x(g enifed#
Try it online!
$endgroup$
add a comment
|
$begingroup$
C++ (gcc), 29 bytes
Function-like macro:
#define f(x)-x//x)x(g enifed#
Try it online!
$endgroup$
C++ (gcc), 29 bytes
Function-like macro:
#define f(x)-x//x)x(g enifed#
Try it online!
answered 7 hours ago
NishiokaNishioka
1614 bronze badges
1614 bronze badges
add a comment
|
add a comment
|
$begingroup$
Befunge-98 (FBBI), 6 bytes
&.@.-&
Try it online! Try it reversed!
$endgroup$
add a comment
|
$begingroup$
Befunge-98 (FBBI), 6 bytes
&.@.-&
Try it online! Try it reversed!
$endgroup$
add a comment
|
$begingroup$
Befunge-98 (FBBI), 6 bytes
&.@.-&
Try it online! Try it reversed!
$endgroup$
Befunge-98 (FBBI), 6 bytes
&.@.-&
Try it online! Try it reversed!
answered 6 hours ago
ovsovs
20.2k2 gold badges13 silver badges62 bronze badges
20.2k2 gold badges13 silver badges62 bronze badges
add a comment
|
add a comment
|
$begingroup$
Stax, 2 bytes
pN
Run and debug it
$endgroup$
add a comment
|
$begingroup$
Stax, 2 bytes
pN
Run and debug it
$endgroup$
add a comment
|
$begingroup$
Stax, 2 bytes
pN
Run and debug it
$endgroup$
Stax, 2 bytes
pN
Run and debug it
answered 6 hours ago
OliverOliver
6,6702 gold badges9 silver badges36 bronze badges
6,6702 gold badges9 silver badges36 bronze badges
add a comment
|
add a comment
|
$begingroup$
Retina 0.8.2, 13 bytes
-*$1#$
)^(|-^
Try it online! It's impossible for the first line to match anything, so nothing happens. In reverse:
^-|(^)
$#1$*-
Try it online! Explanation: Either a leading -
or a leading empty string is matched. This is replaced with -
repeated according to the number of empty strings that were matched.
$endgroup$
add a comment
|
$begingroup$
Retina 0.8.2, 13 bytes
-*$1#$
)^(|-^
Try it online! It's impossible for the first line to match anything, so nothing happens. In reverse:
^-|(^)
$#1$*-
Try it online! Explanation: Either a leading -
or a leading empty string is matched. This is replaced with -
repeated according to the number of empty strings that were matched.
$endgroup$
add a comment
|
$begingroup$
Retina 0.8.2, 13 bytes
-*$1#$
)^(|-^
Try it online! It's impossible for the first line to match anything, so nothing happens. In reverse:
^-|(^)
$#1$*-
Try it online! Explanation: Either a leading -
or a leading empty string is matched. This is replaced with -
repeated according to the number of empty strings that were matched.
$endgroup$
Retina 0.8.2, 13 bytes
-*$1#$
)^(|-^
Try it online! It's impossible for the first line to match anything, so nothing happens. In reverse:
^-|(^)
$#1$*-
Try it online! Explanation: Either a leading -
or a leading empty string is matched. This is replaced with -
repeated according to the number of empty strings that were matched.
answered 3 hours ago
NeilNeil
88.9k8 gold badges46 silver badges188 bronze badges
88.9k8 gold badges46 silver badges188 bronze badges
add a comment
|
add a comment
|
$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!
$endgroup$
add a comment
|
$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!
$endgroup$
add a comment
|
$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!
$endgroup$
Haskell, 8 bytes
Anonymous identity function, turning into subtraction from 0
when reversed.
id--)-0(
Try it online!
Reversed:
(0-)--di
Try it online!
answered 3 hours ago
Ørjan JohansenØrjan Johansen
6,7041 gold badge15 silver badges34 bronze badges
6,7041 gold badge15 silver badges34 bronze badges
add a comment
|
add a comment
|
$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
=-#&
$endgroup$
add a comment
|
$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
=-#&
$endgroup$
add a comment
|
$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
=-#&
$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
=-#&
edited 3 hours ago
answered 3 hours ago
attinatattinat
2,7463 silver badges11 bronze badges
2,7463 silver badges11 bronze badges
add a comment
|
add a comment
|
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).
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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