You will write three functions that plan a route through the map of functional groups and work out its yield.
The idea. The map is a list of arrows (from, to, reagent). A route is a list of kinds of compound. Breadth-first search tries all routes of one step, then two steps, and so on, so the first route that reaches the goal is a shortest one. The overall yield is the product of the step yields.
Your tasks.
next_kinds(kind) so that it returns the list of kinds that can be reached from kind in one step.shortest_route(start, goal) so that it returns the route as a list of kinds, from the start to the goal, with the fewest steps.overall_yield(yields) so that it returns the product of a list of yields written as fractions.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…