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
Building on dwenzel's idea:
airports = [['LAX', 'BWI'], ['BOS', 'SEA'], ['HNL', 'LAX'], ['SEA', 'HNL']] departures, arrivals = airports.transpose first_departure_index = departures.index{|dep| !arrivals.include?(dep)}