rankLength = 16 # 声明数图阶数,即该模式的行(或列)有多少个格子
colsHint = [] # 列的提示数字,二维列表
#coding=utf-8num_list=[
[5, 3, 4, 6, 7, 8, 9, 1, 2],
[6, 7, 2, 1, 9, 5, 3, 4, 8],
[1, 9, 8, 3, 4, 2, 5, 6, 7],
[8, 5, 9, 7, 6, 1, 4, 2, 3],
[4, 2, 6, 8, 5, 3, 7, 9, 1],
[7, 1, 3, 9, 2, 4, 8, 5, 6],
[9, 6, 1, 5, 3, 7, 2, 8, 4],
[2, 8, 7, 4, 1, 9, 6, 3, 5],
[3, 4, 5, 2, 8, 6, 1, 7, 9]
]
tmp = [1,2,3,4,5,6,7,8,9]
def check_shudu(num_list):
#
if len(num_list)<>9:
return -1
#
for j in num_list:
if sorted(j)<>tmp:
return -1
#
for i in range(9):
if sorted([j[i] for j in num_list])<>tmp:
return -1
#
for n in range(3):
for k in range(3):
jiu = []
for i in range(n*3,n*3+3):
for j in range(k*3,k*3+3):
jiu.append(num_list[i][j])
if sorted(jiu)<>tmp:
return -1
return 1
print check_shudu(num_list)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)