[Linux-aus] Only two more days of voting!
James Purser
purserj at k-sit.com
Thu Jan 26 05:19:02 UTC 2006
On Wed, 2006-01-25 at 22:26 +1100, Jonathan Oxer wrote:
> Luckily the order of redistribution made no difference to the final
> result but an equal vote count on the final 2+ candidates when the
> number of remaining candidates is one greater than the number of
> positions is a corner case that should probably be taken into account
> if someone can figure out a nice algorithm for it.
Just a thought on the above.
Assuming your using temp tables to hold the votes for each round, grab
the record with the lowest votes, check to see if there is more than one
record with that number of votes. If there is more than one record, then
dump those records and redistribute.
<Hacky ugly code>
$qstring = "SELECT DISTINCT votes FROM temp_table ORDER BY votes ASC";
$res = pg_query($qstring);
$vote_num = pg_fetch_row($res);
$qstring = "SELECT nom, votes FROM temp_table WHERE votes =
".$vote_num[0];
$res = pg_query($qstring);
while($nom_lowest = pg_fetch_row($res))
{
redistribute($nom_lowest[0]);
}
</Hacky ugly code>
Something like the above should work.
--
James Purser
Producer/Presenter - Linux Australia Update
http://k-sit.com - My Blog
http://la-pod.k-sit.com - Linux Australia Update Podcast,Blog and Forums
Skype: purserj1977
SIP: 736855 at fwd.pulver.com
More information about the linux-aus
mailing list