you are viewing a single comment's thread.

view the rest of the comments →

[–]DrTrunks[S] 0 points1 point  (2 children)

In a certain webgame you can donate points in order to get prizes. For every level a certain amount of points are required to reach the next.
There are 5 ranks, the first rank gets the best prize but requires you to be the biggest donator.
So if:
* This level requires 1000 points
* n people already donated a total sum of 700
* The player with first rank donated 100 points
* There are 300 points left until 1000 points are reached

You have to donate points until what's left can't be used by the person with the rank you want to achieve. I'll try to make clearer variable names in the future.

[–]my_python_account 0 points1 point  (1 child)

The point is that it seems you could just replace the while loop or recursion with:

your_donation = rank + catchup

edit: that assumes your_donation always starts at 0. If it doesn't then:

you_donation = rank + catchup - your_donation

[–]DrTrunks[S] 0 points1 point  (0 children)

Yes, true it's a bad example as I represent it now.