I am trying to solve a problem where I need to find the airport code in an array of arrays of that represents the starting point of a multi-city flight plan.
For example: Given
def find_start(arr)
flat = arr.flatten
first, second = flat.reject { |val| flat.count(val) > 1}
start_city = if flat.index(first) % 2 == 0 #if index of first is even
first
else
second
end
arr.find { |pair| pair[0] == start_city }
end