def _find_friends(cell):
    'Return tuple of cells in same row, column, or subgroup'
    friends = set()
    row, col = cell // n2, cell % n2
    friends.update(row * n2 + i for i in range(n2))
    friends.update(i * n2 + col for i in range(n2))   
    nw_corner = row // n * n3 + col // n * n
    friends.update(nw_corner + i + j for i in range(n) for j in range(0,n3,n2))
    friends.remove(cell)
    return tuple(friends)
Return tuple of cells in same row, column, or subgroup
recipes/Python/473893_Sudoku_Solver/recipe-473893.py