Code works fine except...

John Yeung gallium.arsenide at gmail.com
Mon May 4 22:33:29 EDT 2009


On May 4, 8:56 pm, Ross <ross.j... at gmail.com> wrote:

> Anyways, you're right that seq[0] is always evaluated.
> That's why my algorithm works fine when there are odd
> numbers of players in a league.

It doesn't work fine for all odd numbers of players.  For example, 15
players on 3 courts should result in 5 byes.  But what actually
happens with your code is that you get 4 byes or 8 byes, depending on
whether you've got floating-point division enabled.

So the way you are selecting byes does not even guarantee that you'll
allocate the correct number of active matches for the number of
courts, and this is due to the fact that the extended slice is too
"coarse" a tool for the task.  Now, it may be that for you, the number
of players and courts is always within a confined range such that
extended slicing and your magic constants will work.  That's fine for
you, but we weren't given that information.

I haven't even begun to look at what happens for doubles.

John



More information about the Python-list mailing list