SudokuFunctions.py
def search(values):
    """Apply depth first search to solve Sudoku puzzles in order to solve puzzles
    that cannot be solved by repeated reduction alone.

    Parameters
    ----------
    values(dict)
        a dictionary of the form {'box_name': '123456789', ...}

    Returns
    -------
    dict or False
        The values dictionary with all boxes assigned or False

    Notes
    -----
    You should be able to complete this function by copying your code from the classroom
    and extending it to call the naked twins strategy.
    """
    
    # We start by reducing the puzzle
    values = reduce_puzzle(values)
    # We stop proceding if there is a spot with blank values
    if values is False:
        return False
    if all(len(values[b])==1 for b in values.keys()):
        return values
    
    # Know we look for one box with the fewest digits in order to start with the decision tree
    n,b = min((len(values[b]), b) for b in values.keys() if len(values[b])>1)
    for digit in values[b]:
        new_sudoku = values.copy()
        new_sudoku[b] = digit
        attempt = search(new_sudoku)
        if attempt:
            return attempt
    # We need to include a final return, for the case non of the possibilities above are possible
    return attempt
    
    raise NotImplementedError
Apply depth first search to solve Sudoku puzzles in order to solve puzzles
    that cannot be solved by repeated reduction alone.

    Parameters
    ----------
    values(dict)
        a dictionary of the form {'box_name': '123456789', ...}

    Returns
    -------
    dict or False
        The values dictionary with all boxes assigned or False

    Notes
    -----
    You should be able to complete this function by copying your code from the classroom
    and extending it to call the naked twins strategy.
    
Apply depth first search to solve Sudoku puzzles in order to solve puzzles
that cannot be solved by repeated reduction alone.

Parameters



Returns

dict or False
The values dictionary with all boxes assigned or False

Notes

You should be able to complete this function by copying your code from the classroom
and extending it to call the naked twins strategy.
Apply depth first search to solve Sudoku puzzles in order to solve puzzles that cannot be solved by repeated reduction alone . Parameters Returns dict or False The values dictionary with all boxes assigned or False Notes You should be able to complete this function by copying your code from the classroom and extending it to call the naked twins strategy .
def search(values):
    values = reduce_puzzle(values)
    if values is False:
        return False
    if all(len(values[b])==1 for b in values.keys()):
        return values
    n,b = min((len(values[b]), b) for b in values.keys() if len(values[b])>1)
    for digit in values[b]:
        new_sudoku = values.copy()
        new_sudoku[b] = digit
        attempt = search(new_sudoku)
        if attempt:
            return attempt
    return attempt
    raise NotImplementedError
def search ( values ) : values = reduce_puzzle ( values ) if values is False : return False if all ( len ( values [ b ] ) == 1 for b in values . keys ( ) ) : return values n , b = min ( ( len ( values [ b ] ) , b ) for b in values . keys ( ) if len ( values [ b ] ) > 1 ) for digit in values [ b ] : new_sudoku = values . copy ( ) new_sudoku [ b ] = digit attempt = search ( new_sudoku ) if attempt : return attempt return attempt raise NotImplementedError
Apply depth first search to solve Sudoku puzzles in order to solve puzzles
that cannot be solved by repeated reduction alone.
Apply depth first search to solve Sudoku puzzles in order to solve puzzles that cannot be solved by repeated reduction alone .
"""Apply depth first search to solve Sudoku puzzles in order to solve puzzles
    that cannot be solved by repeated reduction alone.

    Parameters
    ----------
    values(dict)
        a dictionary of the form {'box_name': '123456789', ...}

    Returns
    -------
    dict or False
        The values dictionary with all boxes assigned or False

    Notes
    -----
    You should be able to complete this function by copying your code from the classroom
    and extending it to call the naked twins strategy.
    """ # We start by reducing the puzzle # We stop proceding if there is a spot with blank values # Know we look for one box with the fewest digits in order to start with the decision tree # We need to include a final return, for the case non of the possibilities above are possible
values