"We need to fly home as cheaply as possible so that more money is left for gifts. Aunt Lidia asked for different kinds of cheeses, and Vasya wanted a new toy car. I’ve been looking at the schedule for quite a while and I’m starting to think that some planes are flying in vain".
As the input you get the flight schedule as an array, each element of which is the price of a direct flight between 2 cities (an array of 3 elements - 2 city names as a string, and a flight price).
Planes fly in both directions and the price in both directions is the same. There is a possibility that there are no direct flights between cities.
Find the price of the cheapest flight between cities that are given as the 2nd and 3rd arguments.
Input: 3 arguments: the flight schedule as an array of arrays, city of departure and destination city.
Output: Int. The best price.
cheapest_flight([['A', 'C', 100], ['A', 'B', 20], ['B', 'C', 50]], 'A', 'C') == 70 cheapest_flight([['A', 'C', 100], ['A', 'B', 20], ['B', 'C', 50]], 'C', 'A') == 70
How it can be used: In everyday life to find the optimal combination.
Precondition: Price is always int. The flight schedule contains at least one element. Both cities are in the schedule.
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium