Skip to content

Instantly share code, notes, and snippets.

@hodgesmr
Last active March 5, 2021 04:13
Show Gist options
  • Save hodgesmr/412f6309c8458e72dcc6 to your computer and use it in GitHub Desktop.
Save hodgesmr/412f6309c8458e72dcc6 to your computer and use it in GitHub Desktop.
"""
You have a bunch of plane tickets from a recent multi-stop trip you took.
You dropped the tickets and they all got shuffled up.
Write some Python that takes the list of shuffled tickets
Where each ticket is in the format of (source, destination)
and reconstruct your trip. Output each city you were in, in chronological order.
"""
ticket_list = [ ('lax', 'ewr'), ('ord', 'jfk'), ('mia', 'ord'), ('cvg', 'sfo'), ('jfk', 'lax'), ('ewr', 'atl'), ('sfo', 'mia')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment