## The challenge

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.

 ``````1 2 3 `````` ``````invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] invert([]) == [] ``````

## The solution in Kotlin code

Option 1:

 ``````1 `````` ``````fun invert(arr: IntArray) = arr.map { -it }.toIntArray() ``````

Option 2:

 ``````1 2 3 `````` ``````fun invert(arr: IntArray): IntArray { return IntArray(arr.size){ -arr[it] } } ``````

Option 3:

 ``````1 2 3 4 5 6 7 8 `````` ``````fun invert(arr: IntArray): IntArray { var x = 0 while (x < arr.size) { arr[x] = arr[x] * -1 x++ } return arr } ``````

## Test cases to validate our solution

 `````` 1 2 3 4 5 6 7 8 9 10 11 12 `````` ``````import org.junit.Assert.*; import org.junit.Test class TestExample { @Test fun testFixed() { assertArrayEquals(intArrayOf(-1,-2,-3,-4,-5), invert(intArrayOf(1,2,3,4,5))) assertArrayEquals(intArrayOf(-1,2,-3,4,-5), invert(intArrayOf(1,-2,3,-4,5))) assertArrayEquals(intArrayOf(), invert(intArrayOf())) assertArrayEquals(intArrayOf(0), invert(intArrayOf(0))) } } ``````