填空题
补充下列程序(数独):board = [[5,3,0,0,7,0,0,0,0],[6,0,0,1,9,5,0,0,0],[0,9,8,0,0,0,0,6,0],[8,0,0,0,6,0,0,0,3],[4,0,0,8,0,3,0,0,1],[7,0,0,0,2,0,0,0,6],[0,6,0,0,0,0,2,8,0],[0,0,0,4,1,9,0,0,5],[0,0,0,0,8,0,0,7,9]]def checkBoard(i,j,num):for t in range(9):if t!=j and board[i][t] == num:return Falseif t!= i and board[t][j] == num:return Falsefor t in range(i-i%3, 3+i-i%3):for s in range(j-j%3, 3+j-j%3):if t!=i and s!=j and board[t][s] ==num:return Falsereturn Trueres = []import copydef helper(index):if index==:solution= copy.deepcopy(board)res.append(solution)i =j =if :for num in range(1,10):board[i][j] = numif checkBoard(i,j,num):helper(index+1)else:helper(index+1)
套餐购买该问题答案仅对会员开放,欢迎开通会员 ¥ 19.9
0.64/天
1个月(不限次)
¥ 19.9
1000次
(不限时)
¥ 29.9
0.32/天
3个月(不限次)
¥ 59.9
0.16/天
1年(不限次)
立即支付