SudokuFunctions.py
def reduce_puzzle(values):
    """Reduce a Sudoku puzzle by repeatedly applying all constraint strategies

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

    Returns
    -------
    dict or False
        The values dictionary after continued application of the constraint strategies
        no longer produces any changes, or False if the puzzle is unsolvable 
    """
    
    aux_values = values.copy() # Auxiliar function that will serve to detect when we have reach the end of improvement
    aux_i = True # Auxiliar value that will serve to indicate the end of the reducing algorithm
    while aux_i:
        aux_values = values.copy()
        # We apply the strategies
        values = naked_twins(values)
        values = eliminate(values)
        values = only_choice(values)
        # We check if there have been changes between the new values and the previous values of the sudoku
        differ_boxes = [b for b in values.keys() if values[b] != aux_values[b]]
        # We stop iterating whenever it stops making changes
        if len(differ_boxes)<1:
            aux_i = False
        # We return an error whenever there is a spot without values
        if len([b for b in values.keys() if len(values[b]) == 0]):
            return False
    return values
    
    raise NotImplementedError
Reduce a Sudoku puzzle by repeatedly applying all constraint strategies

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

    Returns
    -------
    dict or False
        The values dictionary after continued application of the constraint strategies
        no longer produces any changes, or False if the puzzle is unsolvable 
    
Reduce a Sudoku puzzle by repeatedly applying all constraint strategies
Parameters



Returns

dict or False
The values dictionary after continued application of the constraint strategies
no longer produces any changes, or False if the puzzle is unsolvable
Reduce a Sudoku puzzle by repeatedly applying all constraint strategies Parameters Returns dict or False The values dictionary after continued application of the constraint strategies no longer produces any changes or False if the puzzle is unsolvable
def reduce_puzzle(values):
    aux_values = values.copy() 
    aux_i = True 
    while aux_i:
        aux_values = values.copy()
        values = naked_twins(values)
        values = eliminate(values)
        values = only_choice(values)
        differ_boxes = [b for b in values.keys() if values[b] != aux_values[b]]
        if len(differ_boxes)<1:
            aux_i = False
        if len([b for b in values.keys() if len(values[b]) == 0]):
            return False
    return values
    raise NotImplementedError
def reduce_puzzle ( values ) : aux_values = values . copy ( ) aux_i = True while aux_i : aux_values = values . copy ( ) values = naked_twins ( values ) values = eliminate ( values ) values = only_choice ( values ) differ_boxes = [ b for b in values . keys ( ) if values [ b ] != aux_values [ b ] ] if len ( differ_boxes ) < 1 : aux_i = False if len ( [ b for b in values . keys ( ) if len ( values [ b ] ) == 0 ] ) : return False return values raise NotImplementedError
Reduce a Sudoku puzzle by repeatedly applying all constraint strategies
Parameters
Reduce a Sudoku puzzle by repeatedly applying all constraint strategies Parameters
"""Reduce a Sudoku puzzle by repeatedly applying all constraint strategies

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

    Returns
    -------
    dict or False
        The values dictionary after continued application of the constraint strategies
        no longer produces any changes, or False if the puzzle is unsolvable 
    """ # Auxiliar function that will serve to detect when we have reach the end of improvement # Auxiliar value that will serve to indicate the end of the reducing algorithm # We apply the strategies # We check if there have been changes between the new values and the previous values of the sudoku # We stop iterating whenever it stops making changes # We return an error whenever there is a spot without values
values