Optimize the algorithm
Optimize the algorithm

Calculate the N for last cookie upfront to avoid unnecessary
calculations.

Improve the precision for the last cookie by summing from the lowest
value.

emaskovsky/puzzles-cookies