예제 #1
0
def solve(SudokuPuzzle):
    '''
        Takes the unsolved Sudoku and returns the solved one
    '''
    if not Sudoku_solver.solveSudoku(SudokuPuzzle):
        return False

    return SudokuPuzzle
예제 #2
0
def main():
    Continue=True
    while Continue==True:
        reset()
        Sudoku_scenario.createScenario()
        Sudoku_view.view()
        print 
        start_time = timeit.default_timer()
        unassignedTiles=Sudoku_validCheck.validChecker(Sudoku_board.board.tileList())
        Sudoku_solver.solveSudoku(unassignedTiles)
        elapsed = timeit.default_timer() - start_time
        print elapsed

        Continue=continues()
        
    print "Thanks for playing!"
    return 
예제 #3
0
def main():
    Continue=True
    while Continue==True:
        reset()
        scen=Sudoku_scenario.createScenario()
        if scen==3:
            start_time = timeit.default_timer()
            Sudoku_validCheck.validChecker(Sudoku_board.board.tileList())
            Sudoku_solver.solveSudoku(Sudoku_board.board.tileList())
            elapsed = timeit.default_timer() - start_time
            print elapsed
        else:
            start_time = timeit.default_timer()
            Sudoku_recursive2.solveSudoku(Sudoku_board.board.tileList())
            elapsed = timeit.default_timer() - start_time
            print elapsed
        Continue=continues()
        
    print "Thanks for playing!"
    return 
예제 #4
0
def main():

    # Initialise Sudoku
    sudoku = [[0 for col in range(9)] for row in range(9)]

    print "\nWelcome to the Sudoku solver.\n\n"

    # Start program, this will only exit if the user enters 0.
    while True:
        printMainOptions()

        # Get the input int value from the user
        try:
            cmd = int(raw_input("\n"))

            # Make sure the value entered is in the bounds
            if cmd < 0 or cmd > 5:
                print "\nPlease enter a number from 0 to 5.\n"
                continue

        # Only allow integer values to be entered
        except ValueError:
            print "\nPlease enter a number from 0 to 5.\n"
            continue


        # User options
        if cmd == 0:
            break

        elif cmd == 1:
            printSudoku(sudoku)

        elif cmd == 2:
            printSudoku(solver.solveSudoku(sudoku))

        elif cmd == 3:
            editor.enterValueMode(sudoku)

        elif cmd == 4:
            editor.clearSudoku(sudoku)

        elif cmd == 5:
            loadEasy(sudoku)