solution.py
def search(values, boxes, peers, maj_dia, min_dia, unitlist, rows, cols):
    "Using depth-first search and propagation, create a search tree and to solve the sudoku."
    " First, reduce the puzzle"
    values = reduce_puzzle(values, peers, maj_dia, min_dia, unitlist, rows, cols, boxes)
    
    if values is False:
        return False # Failed in reduce_puzzle function.
    
    if all(len(values[s]) == 1 for s in boxes): 
        return values
 
    " Choose one of the unfilled squares with the fewest possibilities"
    " Create a subset dictory of boxes with length value."
    unsolved_dict = dict((box,len(values[box])) for box in values.keys() if len(values[box]) != 1)
    ###print (unsolved_dict)
    " Find minimum length box to solve"
    box_to_solve =  min(unsolved_dict, key=unsolved_dict.get)
    ###print(box_to_solve, values[box_to_solve])
    " Now use recursion to solve each one of the resulting sudokus, and if one returns a value (not False), return that answer!"
    digits = values[box_to_solve]
    for digit in digits:
        ###print(type(values[box_to_solve]), type(digit))
        ###print(values[box_to_solve], digit)
        new_sudoku = values.copy()
        new_sudoku[box_to_solve] = digit
        #print("Solving Box ", box_to_solve, " contains ", digit) 
        ##print(new_sudoku[box_to_solve], digit)
        new_sudoku = search(new_sudoku, boxes, peers, maj_dia, min_dia, unitlist, rows, cols)
        if new_sudoku:
            return new_sudoku
Using depth-first search and propagation, create a search tree and to solve the sudoku.
Using depth-first search and propagation, create a search tree and to solve the sudoku.
Using depth - first search and propagation create a search tree and to solve the sudoku .
def search(values, boxes, peers, maj_dia, min_dia, unitlist, rows, cols):
    values = reduce_puzzle(values, peers, maj_dia, min_dia, unitlist, rows, cols, boxes)
    if values is False:
        return False 
    if all(len(values[s]) == 1 for s in boxes): 
        return values
    unsolved_dict = dict((box,len(values[box])) for box in values.keys() if len(values[box]) != 1)
    box_to_solve =  min(unsolved_dict, key=unsolved_dict.get)
    digits = values[box_to_solve]
    for digit in digits:
        new_sudoku = values.copy()
        new_sudoku[box_to_solve] = digit
        new_sudoku = search(new_sudoku, boxes, peers, maj_dia, min_dia, unitlist, rows, cols)
        if new_sudoku:
            return new_sudoku
def search ( values , boxes , peers , maj_dia , min_dia , unitlist , rows , cols ) : " First, reduce the puzzle" values = reduce_puzzle ( values , peers , maj_dia , min_dia , unitlist , rows , cols , boxes ) if values is False : return False if all ( len ( values [ s ] ) == 1 for s in boxes ) : return values " Choose one of the unfilled squares with the fewest possibilities" " Create a subset dictory of boxes with length value." unsolved_dict = dict ( ( box , len ( values [ box ] ) ) for box in values . keys ( ) if len ( values [ box ] ) != 1 ) " Find minimum length box to solve" box_to_solve = min ( unsolved_dict , key = unsolved_dict . get ) " Now use recursion to solve each one of the resulting sudokus, and if one returns a value (not False), return that answer!" digits = values [ box_to_solve ] for digit in digits : new_sudoku = values . copy ( ) new_sudoku [ box_to_solve ] = digit new_sudoku = search ( new_sudoku , boxes , peers , maj_dia , min_dia , unitlist , rows , cols ) if new_sudoku : return new_sudoku
Using depth-first search and propagation, create a search tree and to solve the sudoku.
Using depth - first search and propagation create a search tree and to solve the sudoku .
"Using depth-first search and propagation, create a search tree and to solve the sudoku." " First, reduce the puzzle" # Failed in reduce_puzzle function.
 " Choose one of the unfilled squares with the fewest possibilities" " Create a subset dictory of boxes with length value." ###print (unsolved_dict)
 " Find minimum length box to solve" ###print(box_to_solve, values[box_to_solve])
 " Now use recursion to solve each one of the resulting sudokus, and if one returns a value (not False), return that answer!" ###print(type(values[box_to_solve]), type(digit))
 ###print(values[box_to_solve], digit)
 #print("Solving Box ", box_to_solve, " contains ", digit) 
 ##print(new_sudoku[box_to_solve], digit)

values
boxes
peers
maj_dia
min_dia
unitlist
rows
cols