[Tutor] problem solving with lists

Dennis Lee Bieber wlfraed at ix.netcom.com
Mon Mar 21 12:38:06 EDT 2022


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>

	Everything I understand about it is based upon things like Wikipedia
and research papers...

>How about these as 'meaningful names':
>
>players = "abcdefghijklmnop"
>number_of_weeks = 5
>number_of_groupings = 4
>players_per_grouping = 4
>

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

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



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/



More information about the Tutor mailing list