Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question: Find bus route The data structure of a bus route is a tupple. For example, ('20 Bonner Loop', [1,2,3,4,5,6,7,8]) represents a route. '20 Boner'

Question: Find bus route

The data structure of a bus route is a tupple. For example, ('20 Bonner Loop', [1,2,3,4,5,6,7,8]) represents a route. '20 Boner' is the route name, and the list [1,2,3,4,5,6,7,8] is the bus stops IDs that the route would pass by in order.

The question is to write a function find_route(stops, routes, stop_a, stop_b) to know how to get to stop_b from stop_a. First parameter is a csv file with all stops record, and routes is a csv file with all routes record. The data structure a stop is (0, -35.402611, 149.064747, 'Athllon Dr after Learmonth Dr') with represent ID, latitude, longitude and name. For example, stops[0] means the first record in the file. The function should return such as ('route name', busID, busID2) if no need to change buses. But the case of changing buses should be concerned, which is what I'm stuck in. The function should return a list of tupples, such as [('route name', busID, busID2), ('route name', busID2, busID3)] if the find_route(stops, routes, busID2, busID3) require changing bus one or many times. I have consider using recursive, but it keep failing.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions