Intersection of two dimensional array
arrays, ruby
Solution
Use `#reduce` like
arr1 = [1,2,3,4,5]
arr2 = [5,6,7,8]
arr3 = [5]
bigarr = [arr1,arr2,arr3]
bigarr.reduce(:&) # => [5]
Problem
Is there a simple way to find the intersection of a two dimensional array? For example: ``` arr1 = [1,2,3,4,5] arr2 = [5,6,7,8] arr3 = [5] bigarr = [arr1,arr1,arr3] ``` I know that it's possible to do: ``` intersection = arr1 & arr2 & arr3 # => 5 intersection = big_arr[0] & big_arr[1] & big_arr[2] # => 5 ``` but the number of elements in `big_arr` will vary. I was wondering if there was a simple way to intersect all the elements in `big_arr` regardless of the number of elements.