You will rank prey by profitability and find the best time to stay in a patch that runs down.
The idea. Profitability is . In a patch the gain after seconds is , and the rate over a trip is the gain divided by , where is the travel time. The best stay is the one with the highest rate.
Your tasks.
profitability. It gives the energy per second of handling.best_prey. It takes a list of (name, energy, handling) and gives the name of the most profitable prey.best_stay. Using trip_rate, which is written for you, try stays from 0.1 s to 200 s in steps of 0.1 s and give the stay with the highest rate.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…