标题:求助】判断语句无效,加了flag也还是不行。
取消只看楼主
Uuuuna
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-12-7
结帖率:0
已结贴  问题点数:20 回复次数:1 
求助】判断语句无效,加了flag也还是不行。
代码如下:
def solve(sudoku):
    flag = 0
    list_a = reduce_vr(sudoku)
    list_temp = []
    for i in range(9):
        for j in range(9):
            if len(list_a[i][j]) != 1:
                flag = 1
            else:
                break
    if flag == 1:
        list_temp = trial(sudoku)
        print("1")
    else:
        list_temp = list_a
        print("2")

        return list_temp

run结果如下:
please input your sudoku question:000502000016000080000000000070030010060000000500009000030080000000000200700000509
2
[[8], [9], [4, 7], [5], [1, 4, 6, 7], [2], [1, 3, 4, 6, 7], [3, 4, 6, 7], [1, 4, 7]]
[[2], [1], [6], [3, 4, 7], [9], [3, 4, 7], [3, 4, 7], [8], [5]]
[[3], [5], [4, 7], [1, 4, 6, 7], [1, 4, 6, 7], [8], [1, 4, 6, 7], [9], [2]]
[[4], [7], [2], [8], [3], [5], [9], [1], [6]]
[[1], [6], [9], [4, 7], [2], [4, 7], [8], [5], [3]]
[[5], [8], [3], [1, 4, 6, 7], [1, 4, 6, 7], [9], [4, 7], [2], [4, 7]]
[[9], [3], [5], [2], [8], [1, 4, 6, 7], [1, 4, 6, 7], [4, 6, 7], [1, 4, 7]]
[[6], [4], [1], [9], [5], [3, 7], [2], [3, 7], [8]]
[[7], [2], [8], [1, 3, 4, 6], [1, 4, 6], [1, 3, 4, 6], [5], [3, 4, 6], [9]]

Process finished with exit code 0
搜索更多相关主题的帖子: 无效 flag 语句 sudoku 判断 
2020-12-07 15:38
Uuuuna
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-12-7
得分:0 
我解决了
2020-12-07 17:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-504162-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083229 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved