+ 9

# Challenge: negate number without using minus sign

hey, heres a little challenge: negate a integer but dont use the minus sign. eg: input: 123 //some code without "-" in it output: -123 Answer: https://code.sololearn.com/ctZF3srL79rG/?ref=app

30th Jan 2018, 11:14 PM
Jeremy
+ 20
1st Feb 2018, 10:50 AM
Swapnil Srivastava
31st Jan 2018, 10:59 AM
Daljeet Singh
+ 13
is this accepted? edit: JS based on @Ace's solution ///////// var neg = (num) => ~num + 1; for(var i = 0; i < 20; i++){ var num = Math.floor(Math.random()*999999999); console.log(`Original: \${num}\nNegative: \${neg(num)}\n`); } ////////// https://code.sololearn.com/c8J5t6j4PPcI/?ref=app
30th Jan 2018, 11:25 PM
Burey
+ 13
https://code.sololearn.com/c9Q8ET5pEAhP/?ref=app
31st Jan 2018, 1:26 PM
Infinity
31st Jan 2018, 7:16 PM
LukArToDo
+ 7
No literal minus sign but... https://code.sololearn.com/cgkhwg90141Q/?ref=app It follows the rules but it’s more a joke than anything else 😁
31st Jan 2018, 7:47 AM
A.A.
+ 5
oops posted the wrong one, https://code.sololearn.com/WVzhIQ1ASV9h/?ref=app now it's okay I guess. But my code is similar with @Burey's one, and I am not sure how to do it on the other way...
30th Jan 2018, 11:34 PM
Ice
+ 5
i like all of your submissions so far, very creative :)
31st Jan 2018, 12:03 AM
Jeremy
31st Jan 2018, 9:02 AM
abdulazizumarovich
+ 1
https://code.sololearn.com/cEzLJeH1anud/?ref=app
1st Feb 2018, 11:10 PM
Daniel
+ 1
@Daniel you used the minus sign :p
1st Feb 2018, 11:19 PM
Jeremy
+ 1
As I didnt see any Python Code, here is a similar one to your example Code but in Python =D https://code.sololearn.com/cpn8JaGuvLZe/?ref=app
2nd Feb 2018, 6:35 PM
Lucas Pardo