+ 19

# [CHALLENGE] negative numbers

Another simple challenge. Make all numbers negative except 0. You have integers: 42, -9, 29, -32, 19, 0 . Final data: -42, -9, -29, -32, -19, 0.

15th Feb 2018, 1:36 PM
r8w9
15th Feb 2018, 1:57 PM
Jacob Pembleton
15th Feb 2018, 5:07 PM
Daljeet Singh
+ 13
I took a break from my favourite​ C++ and wrote in Ruby: https://code.sololearn.com/c6Ly5ZQt79IT/?ref=app
16th Feb 2018, 2:03 AM
Eric Zatarack
9th May 2018, 3:10 PM
Uni
+ 8
Hiya! Did you submit this as an assignment via lesson factory? It would be great if you could!
15th Feb 2018, 3:04 PM
jay
+ 8
Here's another approach in C++, nice challenge. Thanks : ) https://code.sololearn.com/cGOUcDx3JJ0I/?ref=app
16th Feb 2018, 6:55 AM
Ipang
15th Feb 2018, 1:45 PM
📈SmileGoodHope📈
+ 7
15th Feb 2018, 5:53 PM
🐙evil octopus
+ 7
15th Feb 2018, 6:14 PM
Med Arezki
15th Feb 2018, 2:49 PM
‎ ‏‏‎Anonymous Guy
+ 5
Your solution is not perfectly correct :) ALL numbers must be negative. Your last negative number in list becomes positive. Try to fix it.
15th Feb 2018, 1:49 PM
r8w9
+ 5
return (nbr==0)?0:Math.abs(nbr)*-1
15th Feb 2018, 3:41 PM
Αητοιπe
+ 4
@A Z M Mushfiqur Rahman It is also not correct. You just rewrote it manually :) that's not good because when you add more numbers the code won't work.
15th Feb 2018, 4:28 PM
r8w9
+ 4
Here is my code in a more mathematical approach. Good challenge for learners! https://code.sololearn.com/coUQH44O5hZJ/?ref=app
15th Feb 2018, 10:40 PM
Andres Ballester
+ 4
In Python - simple and straight: https://code.sololearn.com/cIIDn9HCIXPH/#py
16th Feb 2018, 4:00 AM
Half Byte
+ 3
@jay I'll do it few minutes later :)
15th Feb 2018, 3:11 PM
r8w9
+ 3