[Tutor] problem solving with lists

dn PythonList at DancesWithMice.info
Mon Mar 21 16:47:16 EDT 2022


On 22/03/2022 05.38, Dennis Lee Bieber wrote:
> On Mon, 21 Mar 2022 18:34:40 +1300, dn <PythonList at DancesWithMice.info>
> declaimed the following:
> 
>> Have I managed to understand the problem, this time?
>>
> 	Asking me? <G>

No, but...


> 	I stopped short of going the full OO approach:
> 
> class Schedule:
> 
> class Week:
> 
> class Group:
> 
> maybe (if one doesn't mind the tedium of initializing the alpha placeholder
> with actual player names)
> class Player:
> 
> aschedule = Schedule(group_size, number_groups, number_weeks)
> 
> leading to things like
> 
> aschedule.week[1].group[3].player[2]
> 
> 	Keeping each group as Set of player probably makes the constraint
> checking easier. Technically, the groups in each week are also Set
> ({"abcd", "efgh", "ijkl", "mnop"} and {"ijkl", "pnom", "ehfg", "abcd"} are
> the same groups). And the weeks in the schedule are properly Set, as
> rearranging them doesn't change the solution (the same players are paired
> against each other at some point).

Each constraint/controlling-factor only has one~three 'attributes', so I
happily used built-in data-constructs.

More "modular" or "structured" than OO...


>> Which all serves to make me think that I have yet to grasp the
>> full-measure of the problem!
> 
> 	For all I know, the OP has cherry-picked cases with exactly one
> complete solution. The generalized problem may not have a solution (at the
> extreme, if one specifies too many weeks, one has duplicate pairings; too
> few weeks, and one will have failed to maximize "socialization" by missing
> groupings).

More on this in another msg, but yes the 16-5-4-4 is a
mathematically-elegant combination - as said earlier: no need for 'byes'
which would have added complication!

Someone went to a lot of trouble to tailor a 'toy example' that would
'come out' easily. Salute!
-- 
Regards,
=dn


More information about the Tutor mailing list