Created
January 26, 2024 17:35
-
-
Save vtno/75cb9cd99e0de42290f6e8a5ead91bc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cities = ['BANGKOK', 'ALGIERS', 'ISTANBUL', 'NASSAU', 'JEDDAH', 'WINNIPEG', 'GUATEMALA CITY', 'YASUJ', 'EDMONTON', 'FECAMP', 'ROME', 'PLOVDIV', 'OSAKA', 'UTRECHT', 'DAR ES SALAAM', 'KUALA LUMPUR', | |
'MAZAR E SHARIF', 'SHANGHAI', 'TOKYO', 'LUCKNOW', 'HYDERABAD'] | |
current = cities.shift | |
until cities.empty? | |
cities.each_with_index do |city, index| | |
if city[0] == current[-1] | |
current = city | |
cities.delete_at(index) | |
end | |
end | |
end | |
p cities.first |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment