The Kirkman's Schoolgirl Problem aims to form groups of three girls for some 'n' number of days such that no pair of girls are ever together more than once in the same group. For this I was working with 9 girls that need to be divided in groups of three for 4 days.
I am very new to Python. I would like to avoid fancy modules for now, so I can get my basics right.
Here is my code:
prob = ['ariana', 'barbara', 'cindy', 'darlyn', 'emily', 'felicia', 'gwanyth', 'hilton', 'india', 'julie']
same_grps = []
days_arrangement = []
while len(days_arrangement)<=4:
today = []
same_day = []
for i in range(3):
while True:
temp = []
temp_same_day = []
for j in range(3):
for girl in prob:
if girl not in temp_same_day:
temp.append(girl)
temp_same_day.append(girl)
if temp in same_grps:
continue
if temp not in same_grps:
grp = temp[::]
same_grps.append(grp)
today.append(grp)
break
days_arrangement.append(today)
print(days_arrangement)
When I run it the kernel doesn't respond, as if stuck in some infinite loop and gives no output.