You will store the aliphatic map as a dictionary and let the program find the shortest route between two families.
The idea. Each key is a family. Its value is a dictionary of the families you can reach in one step, with the reagent. A search that looks at all one-step neighbours first, then all two-step ones, finds the shortest route. This is called a breadth-first search.
Your tasks.
neighbours(family): the list of families one step away.reagents(route): the list of reagents along a route, one for each arrow.nitrile to amine with the reagent LiAlH4.Run your code once to unlock the worked solution.
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…