Algorithm for rank points
#5

True, although for small values you won`t have a problem.
But if you must..if you know the maximum level before hand, DP can be used (dynamic programming)

pawn Код:
levelPoints(level)
{
    new points[100];
    points[0] = 0;
    for(new i=1; i <= level; ++i) {
        points[i] = points[i-1] + 10*i;
    }

    return points[level];
}
EDIT:
In this case the array isn`t even needed.

pawn Код:
levelPoints(level)
{
    new points = 0;
    for(new i=1; i <= level; ++i) {
        points += 10*i;
    }

    return points;
}
Reply


Messages In This Thread
Algorithm for rank points - by MP2 - 05.11.2015, 11:22
Re: Algorithm for rank points - by Karan007 - 05.11.2015, 11:25
Re: Algorithm for rank points - by Macluawn - 05.11.2015, 11:41
Re: Algorithm for rank points - by MP2 - 05.11.2015, 11:43
Re: Algorithm for rank points - by Macluawn - 05.11.2015, 11:47
Re: Algorithm for rank points - by MP2 - 05.11.2015, 11:49
Re: Algorithm for rank points - by Macluawn - 05.11.2015, 11:55
Re: Algorithm for rank points - by MP2 - 05.11.2015, 12:05
Re: Algorithm for rank points - by Macluawn - 05.11.2015, 12:20
Re: Algorithm for rank points - by AbyssMorgan - 05.11.2015, 14:28

Forum Jump:


Users browsing this thread: 2 Guest(s)