- 数独验证
- 2023-02-08 19:33:02 @
# 读取数据
read_number = int(input())
test_data = [] # 行列表
clo_list = [] # 列列表
area_list = [] # 3×3列表
for data_count in range(read_number):
test_data.append([])
clo_list.append([])
area_list.append([])
for _ in range(9):
clo_list[data_count].append([])
area_list[data_count].append([])
for row_count in range(9):
n = input()
n_s = n.split(" ")
# 写入行列表
test_data[data_count].append(n_s)
# 写入列列表
for clo_count in range(9):
clo_list[data_count][clo_count].append(n_s[clo_count])
# 写入33列表
for clo_count in range(9):
if clo_count <= 2 and row_count <= 2:
area_list[data_count][0].append(n_s[clo_count])
elif clo_count > 2 and row_count <= 2 and clo_count <= 5:
area_list[data_count][1].append(n_s[clo_count])
elif clo_count > 5 and row_count <= 2:
area_list[data_count][2].append(n_s[clo_count])
elif clo_count <= 2 and row_count > 2 and row_count <= 5:
area_list[data_count][3].append(n_s[clo_count])
elif clo_count > 2 and row_count > 2 and clo_count <= 5 and row_count <=5:
area_list[data_count][4].append(n_s[clo_count])
elif clo_count > 5 and row_count > 2 and row_count <= 5:
area_list[data_count][5].append(n_s[clo_count])
elif clo_count <= 2 and row_count > 5:
area_list[data_count][6].append(n_s[clo_count])
elif clo_count > 2 and row_count > 5 and clo_count <= 5:
area_list[data_count][7].append(n_s[clo_count])
elif clo_count > 5 and row_count > 5:
area_list[data_count][8].append(n_s[clo_count])
input()
# print(test_data)
#print(clo_list)
# print(area_list)
test_result=[]
for part_count in range(len(test_data)):
pass_ = True
# 检查行
for one_line in test_data[part_count]:
if len(set(one_line)) != len(one_line):
# print(str(part_count)+"行检查")
pass_ = False
test_result.append("Wrong")
break
if not pass_:
continue
# 检查列
for one_line in clo_list[part_count]:
if len(set(one_line)) != len(one_line):
# print(str(part_count)+"列检查")
pass_ = False
test_result.append("Wrong")
break
if not pass_:
continue
# 检查33
for one_line in area_list[part_count]:
if len(set(one_line)) != len(one_line):
# print(str(part_count)+"33检查")
pass_ = False
test_result.append("Wrong")
break
if not pass_:
continue
test_result.append("Right")
for a in test_result:
print(a)
0 条评论
目前还没有评论...