I hope this is the right forum for this question.

Although I'm working in PHP, I really just need the algorithm (in pseudocode preferably) for a complex (at least seems to me) scoring system. The algorithm should always place the highest number of correct answers at the top of the list and use remaining clock time as bonus (mainly used as a tie breaker). Essentially, I want to rank users based on accuracy (correct or incorrect) with a speed bonus (remaining clock time)

Essentially we collect points per question, clock time left per question (higher amount = faster answer) and number of correct answers.

The problem I'm having is figuring out how to implement the time left as a bonus. What I've run across is that the time bonus ends up making up for missed questions. Also, different questions may have different weights (ie Q1 is worth 50 points, Q2 is worth 20 points, etc...) which then adds a complexity to the algorithm. Also, clock time per question may also vary. Here's an example:

userid   num_correct   total_points   total_clock
  1          7              315           625
  2          4              423           742
  3          9              647           716
  4          2              186           573
  5          4              423           218
  6          4              515           185

With this list, id number 3 should be first since they got 9 correct, followed by id 1.
Third place should be id 6 since they had the third highest correct, but also had a higher point score. then fourth place should be id 2 since they had a higher clock.

Obviously my issue isn't sorting, that's the easy part. What I need to figure out is how to calculate a total score that would correlate with the order. Essentially, num_correct has a higher weight than total points than total clock.

Here's what I have with the help of MS Excel

-min(total_points) * .75                                       ==> [max_allowed], max amount of bonus points (clock points). The .75 was an arbitrary number in order for max_allowed to be less than the least amount of points recorded so that the clock points can't make up for a missed question
-max(total_clock)                                              ==> [max_clock], time leader of which we'll use to rate clocks as a percentage
-if(id.total_clock > max_allowed, max_allowed, id.total_clock) ==> [clock_points]
-clock_points + (num_correct * (total_clock / max_clock))      ==> [weighted_clock]
-total_points + (num_correct * (average_points / 2))           ==> [weighted_points]
-weighted_clock + weighted_points                              ==> [total_score]

The issues with this "algorithm" is that average_points is an arbitrary preset number. I won't always know what that number is going to be therefore if each question has a different point scheme, this "algorithm" will fail.

Any one have any ideas? I'm not stuck to this algorithm and I'm looking for some suggestions that would give me a total_score that would match with the sorting described above.

Thanks in advance!

6 Years
Discussion Span
Last Post by Momerath

First normalize the score. What I mean by this is divide the score they received by (max score + 1). This will give you a result that goes from zero to one (with one excluded). Round this number off to however many decimals you like (say 3) so you have a value from 0.000 to 0.999.

Do the same with the time, again getting a number from 0.000 to 0.999. Divide this number by 1000 resulting in a number from 0.000000 to 0.000999.

Add the number right, the normalized score and the normalized time. This will give you numbers that you can sort into descending order as their final score.

Taking your numbers as an example, and saying max score = 999 and max time = 999 (makes life easy :)) we get

user id    correct    points    clock        norm point    norm clock        Score
1            7          315      625            0.315       0.000625        7.315625
2            4          423      742            0.423       0.000742        4.423742
3            9          647      716            0.647       0.000716        9.647716
4            2          186      573            0.186       0.000573        2.186573
5            4          423      218            0.423       0.000218        4.423218
6            4          515      185            0.515       0.000185        4.515185

As you can see, user #3 has the highest score, followed by 1, 6, 2, 5 then 4

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.