SudokuFunctions.py
def redefine_units(diagonal=True):
    """Includes the diagonal units and arranges the units and peers dictionaries
    in case we are dealing with a Diagonal Sudoku.

    DIAGONAL SUDOKUS are based on the regular Sudokus. Diagonal Sudokus mantain the
    rule that only one number 1-9 must appear in each row, column and 3x3 square.
    Additionally, Diagonal Sudokus state that each main diagonal (from top-left-corner
    to bottom-right-corner and the other way around) must also have only once each
    number from 1 to 9.

    Parameters
    ----------
    diagonal(bool)
        it indicates if the diagonal units should be added to the unitlists or not,
        depending on the Sudoku type

    CHANGES GLOBALLY
    ----------------
    unitlist
        a sequence of lists, each of them with a different unit from the Sudoku
        (i.e., the first row, the second column or the top-left 3x3 square)
    units
        a new dictionary with a key for each box (string) whose value is a list
        containing the units that the box belongs to (i.e., the "member units")
    peers
        a new dictionary with a key for each box (string) whose value is a set
        containing all boxes that are peers of the key box (boxes that are in a unit
        together with the key box)
    """
    
    global unitlist, units, peers, unitlist_reg, units_reg, peers_reg, unitlist_diag, units_diag, peers_diag
    
    if diagonal:
        # We assign the values to the global variables, so each function can access the proper values
        unitlist, units, peers = unitlist_diag, units_diag, peers_diag
    else:
        # We assign the values to the global variables, so each function can access the proper values
        unitlist, units, peers = unitlist_reg, units_reg, peers_reg
Includes the diagonal units and arranges the units and peers dictionaries
    in case we are dealing with a Diagonal Sudoku.

    DIAGONAL SUDOKUS are based on the regular Sudokus. Diagonal Sudokus mantain the
    rule that only one number 1-9 must appear in each row, column and 3x3 square.
    Additionally, Diagonal Sudokus state that each main diagonal (from top-left-corner
    to bottom-right-corner and the other way around) must also have only once each
    number from 1 to 9.

    Parameters
    ----------
    diagonal(bool)
        it indicates if the diagonal units should be added to the unitlists or not,
        depending on the Sudoku type

    CHANGES GLOBALLY
    ----------------
    unitlist
        a sequence of lists, each of them with a different unit from the Sudoku
        (i.e., the first row, the second column or the top-left 3x3 square)
    units
        a new dictionary with a key for each box (string) whose value is a list
        containing the units that the box belongs to (i.e., the "member units")
    peers
        a new dictionary with a key for each box (string) whose value is a set
        containing all boxes that are peers of the key box (boxes that are in a unit
        together with the key box)
    
Includes the diagonal units and arranges the units and peers dictionaries
in case we are dealing with a Diagonal Sudoku.

DIAGONAL SUDOKUS are based on the regular Sudokus. Diagonal Sudokus mantain the
rule that only one number 1-9 must appear in each row, column and 3x3 square.
Additionally, Diagonal Sudokus state that each main diagonal (from top-left-corner
to bottom-right-corner and the other way around) must also have only once each
number from 1 to 9.

Parameters

diagonal(bool)
it indicates if the diagonal units should be added to the unitlists or not,
depending on the Sudoku type

CHANGES GLOBALLY

unitlist
a sequence of lists, each of them with a different unit from the Sudoku

units
a new dictionary with a key for each box (string) whose value is a list
containing the units that the box belongs to
peers
a new dictionary with a key for each box (string) whose value is a set
containing all boxes that are peers of the key box (boxes that are in a unit
together with the key box)
Includes the diagonal units and arranges the units and peers dictionaries in case we are dealing with a Diagonal Sudoku . DIAGONAL SUDOKUS are based on the regular Sudokus . Diagonal Sudokus mantain the rule that only one number 1 - 9 must appear in each row column and 3x3 square . Additionally Diagonal Sudokus state that each main diagonal ( from top - left - corner to bottom - right - corner and the other way around ) must also have only once each number from 1 to 9 . Parameters diagonal ( bool ) it indicates if the diagonal units should be added to the unitlists or not depending on the Sudoku type CHANGES GLOBALLY unitlist a sequence of lists each of them with a different unit from the Sudoku units a new dictionary with a key for each box ( string ) whose value is a list containing the units that the box belongs to peers a new dictionary with a key for each box ( string ) whose value is a set containing all boxes that are peers of the key box ( boxes that are in a unit together with the key box )
def redefine_units(diagonal=True):
    global unitlist, units, peers, unitlist_reg, units_reg, peers_reg, unitlist_diag, units_diag, peers_diag
    if diagonal:
        unitlist, units, peers = unitlist_diag, units_diag, peers_diag
    else:
        unitlist, units, peers = unitlist_reg, units_reg, peers_reg
def redefine_units ( diagonal = True ) : global unitlist , units , peers , unitlist_reg , units_reg , peers_reg , unitlist_diag , units_diag , peers_diag if diagonal : unitlist , units , peers = unitlist_diag , units_diag , peers_diag else : unitlist , units , peers = unitlist_reg , units_reg , peers_reg
Includes the diagonal units and arranges the units and peers dictionaries
in case we are dealing with a Diagonal Sudoku.
Includes the diagonal units and arranges the units and peers dictionaries in case we are dealing with a Diagonal Sudoku .
"""Includes the diagonal units and arranges the units and peers dictionaries
    in case we are dealing with a Diagonal Sudoku.

    DIAGONAL SUDOKUS are based on the regular Sudokus. Diagonal Sudokus mantain the
    rule that only one number 1-9 must appear in each row, column and 3x3 square.
    Additionally, Diagonal Sudokus state that each main diagonal (from top-left-corner
    to bottom-right-corner and the other way around) must also have only once each
    number from 1 to 9.

    Parameters
    ----------
    diagonal(bool)
        it indicates if the diagonal units should be added to the unitlists or not,
        depending on the Sudoku type

    CHANGES GLOBALLY
    ----------------
    unitlist
        a sequence of lists, each of them with a different unit from the Sudoku
        (i.e., the first row, the second column or the top-left 3x3 square)
    units
        a new dictionary with a key for each box (string) whose value is a list
        containing the units that the box belongs to (i.e., the "member units")
    peers
        a new dictionary with a key for each box (string) whose value is a set
        containing all boxes that are peers of the key box (boxes that are in a unit
        together with the key box)
    """ # We assign the values to the global variables, so each function can access the proper values # We assign the values to the global variables, so each function can access the proper values
diagonal