“““ file: Sudoku.py author: Michael Washburn Jr nk.net> description: A self generating Sudoku game using a tkinter based GUI. “““ from copy import deepcopy from random import randrange shuffle from tkinter import *
def init(): “““ initializes the random sudoku board. Returns: board - A 2D array representation of the sudoku board key - a solved board “““ board = [None] * 9 for n in range(0len(board)): board[n] = [None] * 9 board = randomize(board) board = solve(board) key = deepcopy(board) board = removeSpots(board) return board key
def solutions(board): “““ finds out all possible solutions to a board configuration. - used to see if a board is valid Returns: sol
评论
共有 条评论