Code works fine except...

John Yeung gallium.arsenide at gmail.com
Mon May 4 01:16:20 EDT 2009


On May 3, 11:29 pm, Chris Rebert <c... at rebertia.com> wrote:

> Probably not the cause of the problem, but where
> did the magic numbers 1.072 and 1.08 come from?

It is perhaps not the most direct cause of the problem, in the sense
that the magic numbers could take various values and the problem would
still be there.  But the magic numbers appear to be used for
"spreading out" bye selection, and that's broken.

The extended slice as written will always pick the first element,
since the step is guaranteed to be positive.  Since the first player
(or None, when there are an odd number of players) stays put in the
first position during the round_robin shuffle, that player will always
be selected for a bye.

Further, as written, the calculated number of byes has no bearing on
the actual number of byes selected.

I think what I would do is adjust the shuffling algorithm in such a
way that everyone moves through the various positions in the list
(would it be as simple as adding a shift at the end of
round_robin???).  Then I could simply select the byes from one end of
the list (with a regular slice instead of an extended slice).

John



More information about the Python-list mailing list