40
2
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
.
5Why do we need a copy of the same question? – Christian – 2019-09-18T07:30:59.957
5@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. – Adám – 2019-09-18T07:32:12.453
5A yes, now I see the difference. One needs to read VERY carefully – Christian – 2019-09-18T07:34:31.927
If using a structured language like C#, are you just reversing lines? – Emma - PerpetualJ – 2019-09-19T02:31:03.343
@PerpetualJ No, look at the source like list of characters, some of which are line breaks. – Adám – 2019-09-19T05:42:56.903