免费玩数独游戏(推荐一款数独游戏)

2023-07-23 03:11:27
手游app游戏网 > 手游app游戏网 > 免费玩数独游戏(推荐一款数独游戏)

有趣的数独游戏是人见人爱,老少咸宜的数字逻辑推理游戏。

首先增强了孩子们的数感和数字推理能力,行、列、宫之间的数字奥秘同时也需要具备超强的观察力、专注力。喜欢数独游戏的孩子,数学思维都很不错。也几乎是所有数学老师推荐的。

(ps: 可以使用单步调试,查看每次递归,in_sd_matrix 矩阵的数值变化)

学生分享

学生分享

"""打印矩阵""" def print_sd(in_sd_matrix, out_sd_matrix, question_type, answer_type): """ 打印矩阵 :param in_sd_matrix: 输入矩阵 :param out_sd_matrix: 输出矩阵 :param question_type: 问题颜色 :param answer_type: 答案颜色 :return: """ head_line = ("+" + "+=====" * 3) * 3 + "++" mid_line = ("+" + "+-----" * 3) * 3 + "++" for i in range(len(in_sd_matrix)): new_line = '' for j in range(len(in_sd_matrix[i])): if j == 0: new_line += "||" if in_sd_matrix[i][j] != 0: new_line += " %s " % (question_type % str(in_sd_matrix[i][j])) else: new_line += " %s " % (answer_type % (str(out_sd_matrix[i][j]) if out_sd_matrix[i][j] != 0 else ' ')) if (j + 1) % 3 != 0: new_line += "|" elif (j + 1) % 3 == 0: new_line += "||" if i == 0: print(head_line) print(new_line) if (i + 1) % 3 != 0: print(mid_line) elif (i + 1) % 3 == 0: print(head_line)

"""判断当前位置能否填指定数字""" def can_fit(in_sd_matrix, row_index:int, col_index:int, num): # 判断当前行是否出现重复的非零数字 for k in range(len(in_sd_matrix[row_index])): if k != col_index and in_sd_matrix[row_index][k] == num: return False # 判断当前列是否出现重复的非零数字 for k in range(len(in_sd_matrix)): if k != row_index and in_sd_matrix[k][col_index] == num: return False # 判断当前矩阵是否出现重复的非零数字 cube_i, cube_j = int(row_index / 3), int(col_index / 3) for k in range(cube_i * 3, (cube_i + 1) * 3): for p in range(cube_j * 3, (cube_j + 1) * 3): if k != row_index and p != col_index and in_sd_matrix[k][p] == num: return False return Tru

作者:admin | 分类:手游app游戏网 | 浏览:26 | 评论:0