带Sudoku网格的Python中的J面板或熊猫面板

时间:2018-10-02 20:19:11

标签: python pandas sudoku

我正在为我在学校上课的Sudoku游戏工作,我想知道如何将2D矩阵转换为一种格式,这样看起来像一个真正的Sudoku。我做了一些研究,发现应该使用J-panels或Panda面板。我做了一些摆弄,但是我不能为每个数字得到单独的正方形,但是它只是在矩阵上打印了空格而不是逗号。我需要一些帮助,因为这是我本学期的最后一个项目。我在这里也有一个工作代码:https://repl.it/@DracoChiko/My-complete-Sudoku-game

EASY_GRID = [[6, 1, 0, 0, 0, 0, 0, 0, 0,],
[0, 4, 8, 0, 5, 3, 1, 0, 2],
[0, 0, 3, 0, 8, 0, 0, 4, 5],
[4, 0, 0, 0, 9, 0, 5, 0, 6],
[0, 5, 7, 0, 3, 0, 5, 0, 0],
[3, 0, 0, 5, 0, 8, 0, 1, 0],
[0, 3, 9, 0, 0, 0, 6, 2, 1],
[7, 2, 0, 0, 6, 5, 3, 0, 0],
[8, 0, 4, 3, 0, 2, 0, 5, 9]]

EASY_ANSWER = [[6, 1, 5, 2, 4, 9, 8, 7, 3],
[9, 4, 8, 7, 5, 3, 1, 6, 2],
[2, 7, 3, 6, 8, 1, 9, 4, 5],
[4, 8, 2, 1, 9, 7, 5, 3, 6],
[1, 5, 7, 4, 3, 6, 2, 9, 8],
[3, 9, 6, 5, 2, 8, 4, 1, 7],
[5, 3, 9, 8, 7, 4, 6, 2, 1],
[7, 2, 1, 9, 6, 5, 3, 8, 4],
[8, 6, 4, 3, 1, 2, 7, 5, 9]]

print ("  ", "1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9")
GRIDSET = 0
GRIDSETTER = 1
for row in EASY_GRID:
  print (GRIDSETTER, EASY_GRID[GRIDSET])
  GRIDSETTER += 1
  GRIDSET += 1

0 个答案:

没有答案