FunctionRacerProblemsRace

Break-Even Rate

MediumSciPyPython

A project costs money now and pays back later: flows[0] is negative, every later flow is positive or zero, and flows[t] arrives after t years. Its value at yearly rate r is the sum of flows[t] / (1 + r)**t. Return the rate, between -0.9 and 10, at which that value is exactly 0. Answers within 0.00001 of the right one are accepted.

Example 1

flows [-100,110]
returns 0.1

100 now for 110 in a year is a 10% return.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More SciPy problems