Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 482 Bytes

insert_values.md

File metadata and controls

20 lines (16 loc) · 482 Bytes

Description

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

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

You can assume that all values are integers. Do not mutate the input array/list.

My Solution

def invert(list)
  list.map { |el| -el }
end