I'm trying to distribute prizes based on scores. I'm having trouble with my logic when it comes to TIE's. Can anyone give me logic pointers on handling a tie between 3 or more people?
UPDATE: The Goal is this --
- Make an ARRAY of the people who have tied (Only them)
- Know what POSITION those people are in.
I have a few sample phases you can skim through:
Example 1 - Works with 0 Ties
<?php
function give_prize($a, $b) {return;}
$prize = array(500, 250, 75);
$user = array(
'user1' => 650,
'user2' => 500,
'user3' => 200,
'user4' => 100,
);
$prize_count = count($prize);
for ($i = 0; $i < $prize_count; $i++) {
give_prize($user[$i], $prize[$i]);
}
Example 2 - Works with 1 Tie (Is it a good way?)
<?php
for ($i = 0; $i < $prize_count; $i++) {
if (isset($user[$i+1])) {
if ($user[$i] == $user[$i++]) {
// My Tie breaker code
}
}
}
But what would I do in a tie of 3 or 4 people? Should I follow the above and do more if checks?