You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
305 B
Ruby

# Write a function (similar to _.difference) that takes two arrays
# and returns two arrays containing the elements not present in the other
def difference(arr1, arr2)
result_1 = arr1.reject { |num| arr2.include?(num) }
result_2 = arr2.reject { |num| arr1.include?(num) }
[result_1, result_2]
end