GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — daily_coding_problem/problems/41/problem_41.py at master · ihossai4/daily_coding_problem Expand file tree/ Copy pathproblem_41.pyMore file actions 23 lines (17 loc) · 965 Bytes / Copy pathproblem_41.pyFile metadata and controls23 lines (17 loc) · 965 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 def coding_problem_41(flights_db, starting_airport): """ Given an unordered list of flights taken by someone, each represented as (origin, destination) pairs, and a starting airport, compute the person's itinerary. If no such itinerary exists, return null. If there are multiple possible itineraries, return the lexicographically smallest one. All flights must be used in the itinerary. Examples: >>> coding_problem_41([('SFO', 'HKO'), ('YYZ', 'SFO'), ('YUL', 'YYZ'), ('HKO', 'ORD')], 'YUL') ['YUL', 'YYZ', 'SFO', 'HKO', 'ORD'] >>> coding_problem_41([('SFO', 'COM'), ('COM', 'YYZ')], 'COM') # returns None >>> coding_problem_41([('A', 'B'), ('A', 'C'), ('B', 'C'), ('C', 'A')], 'A') ['A', 'B', 'C', 'A', 'C'] The itinerary ['A', 'C', 'A', 'B', 'C'] is also a valid however the first one is lexicographically smaller. """ pass if __name__ == '__main__': import doctest doctest.testmod(verbose=True) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |