[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Linux-aus] Only two more days of voting!



On Thu, 2006-01-26 at 08:18 +1100, James Purser wrote:
> 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.

But "dump those records and redistribute" doesn't work if you have 4
people left, 3 positions to fill and the two lower voted people with the
same number of votes.

This is the tricky problem.

I also am not currently using temporary tables. possibly should be...
not sure if it'd help in performance. Although I'm not caring so much
about performance. I care more about correctness.

> <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.

patches welcome :)

-- 
Stewart Smith (stewart@linux.org.au)
Committee Member, Linux Australia

Attachment: signature.asc
Description: This is a digitally signed message part