Answered step by step
Verified Expert Solution
Question
1 Approved Answer
we would like to encourage passengers to experience the joy of travel using................ (please open pictures in new tab for full size) Wc would like
we would like to encourage passengers to experience the joy of travel using................ (please open pictures in new tab for full size)
Wc would like to encourage passergers to experienoe tha jcy of travel using our transit system, thercfore we would liks to determins the lcngest path available to advertise to the public. Specifically we would like ta determine the lonaest possible trip on the transit system that will involve two tickets. The destinations must be connected, and all clestinations must be unique. You will be provided input in the format of CHI NYC:719 where CHI is one location, MYC is a connected location and 719 is the distance between the locations. One line of output should be pro ided per line ofinput in the form at of 167: CHI : NYC: LA where 3167 is the distance of the trip, CHI is the starting location, NYC s the intermediarv location, and LA is the final location Example: Sequence Input Output Note NONE There is no path that involves three distinct locations The longest path involves traveling from CHI to LA through NYC The longest path involves traveling from LA to SEATTLE through NYC The longest path now CHI : NYC : 719 2 NYC:LA:2414 3133: CHI : NYC : LA NYC: SEATTLE:24484862: LA: NYC:SEATTLE 4 NYC: HANA!! :4924 7372: HAWAII: NYC :SEATTLE is to travel from HAWAll to SEATTLE through NYC. This is an illustration of the paths after the 4th input has been read: SEATTLE 2448 NYC 719 CHI 4924 2414 LA HAWAII Note: If you get multiple longest trips with equal distances, sort the trips in alphabetical order and return the first. So, choose CHI: NYC: LA instead of LA: NYC :CHI . 1 import fileinput 2 class PathCalculator: 3 4 # You may enter code here. def process (self, line: str) -> str: 6 7 8 # You must enter code here. 9 if name --" _main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started