我怎样才能解决这个柯克曼的女学生问题?

问题描述

柯克曼的女学生问题旨在将三个女孩组成一组,持续几天,这样在同一组中,没有一对女孩会在一起超过一次。为此,我与 9 个女孩一起工作,她们需要分成三人一组,为期 4 天。

我对 Python 非常陌生。我现在想避免使用花哨的模块,这样我才能正确地掌握基础知识。

这是我的代码

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)

当我运行它时,内核没有响应,好像陷入了某个无限循环并且没有输出

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)