Skip to content

Instantly share code, notes, and snippets.

View hayd's full-sized avatar
😎
chillin'

Andy Hayden hayd

😎
chillin'
View GitHub Profile
@hayd
hayd / sudukoObject.py
Created July 13, 2012 16:48
Sudoku object - with hints
#Note this requires the function solve_sudoku.
def Sudoku(grid):
def __init__(self):
self.grid = grid
self.solution = solve_sudoku(self.grid)
self.hints = self.get_hints()
def solvable(self):
return bool(self.solution)
@hayd
hayd / cs258ps3sudokuCheckAndFill.py
Created July 12, 2012 13:07
Sudoku checker - checks whether a sudoku grid is allowable, or completable (and if so fills it in)
def check_sudoku(grid):
'''If grid is a valid sudoku board, so far filled-in correctly: returns True
else if grid is a valid sudoku board but has been filled-in incorrectly: returns False
else: returns None
Note: returning True does not imply there is a solution for grid, see solve_sudoku.
'''
def sanity_check():
'''If grid is of the sudoku board format: returns True
else: returns None