



from sklearn.metrics import matthews_corrcoef

import datasets


_lowercase: List[Any]      			=		"\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. It takes\ninto account true and false positives and negatives and is generally\nregarded as a balanced measure which can be used even if the classes are of\nvery different sizes. The MCC is in essence a correlation coefficient value\nbetween -1 and +1. A coefficient of +1 represents a perfect prediction, 0\nan average random prediction and -1 an inverse prediction.  The statistic\nis also known as the phi coefficient. [source: Wikipedia]\n"

_lowercase: Optional[Any]      			=		"\nArgs:\n    predictions (list of int): Predicted labels, as returned by a model.\n    references (list of int): Ground truth labels.\n    sample_weight (list of int, float, or bool): Sample weights. Defaults to `None`.\nReturns:\n    matthews_correlation (dict containing float): Matthews correlation.\nExamples:\n    Example 1, a basic example with only predictions and references as inputs:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.54\n\n    Example 2, the same example as above, but also including sample weights:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 3, 1, 1, 1, 2])\n        >>> print(round(results['matthews_correlation'], 2))\n        0.1\n\n    Example 3, the same example as above, but with sample weights that cause a negative correlation:\n        >>> matthews_metric = datasets.load_metric(\"matthews_correlation\")\n        >>> results = matthews_metric.compute(references=[1, 3, 2, 0, 3, 2],\n        ...                                     predictions=[1, 2, 2, 0, 3, 3],\n        ...                                     sample_weight=[0.5, 1, 0, 0, 0, 1])\n        >>> print(round(results['matthews_correlation'], 2))\n        -0.25\n"

_lowercase: Union[str, Any]      			=		"\\n@article{scikit-learn,\n  title={Scikit-learn: Machine Learning in {P}ython},\n  author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n         and Thirion, B. and Grisel, O. and Blondel, M. and Prettenhofer, P.\n         and Weiss, R. and Dubourg, V. and Vanderplas, J. and Passos, A. and\n         Cournapeau, D. and Brucher, M. and Perrot, M. and Duchesnay, E.},\n  journal={Journal of Machine Learning Research},\n  volume={12},\n  pages={2825--2830},\n  year={2011}\n}\n"



@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION,      _KWARGS_DESCRIPTION	)
class 	_lowercase							(   datasets.Metric	):





	"""simple docstring"""




	def      UpperCamelCase_       (self		):
						"""simple docstring"""

						return datasets.MetricInfo(
						    description=_DESCRIPTION		,       citation=_CITATION		,       inputs_description=_KWARGS_DESCRIPTION		,       features=datasets.Features(
						        {
						            "predictions": datasets.Value("int32"		),
						            "references": datasets.Value("int32"		),
						        }		)		,       reference_urls=[
						        "https://scikit-learn.org/stable/modules/generated/sklearn.metrics.matthews_corrcoef.html"
						    ]		,       )




	def      UpperCamelCase_       (self		,       lowerCamelCase_		,       lowerCamelCase_		,       lowerCamelCase_=None		):
						"""simple docstring"""

						return {
						    "matthews_correlation": float(matthews_corrcoef(lowerCamelCase_		,       lowerCamelCase_		,       sample_weight=lowerCamelCase_		)		),
						}





from __future__ import annotations

_lowercase: Tuple      			=		list[list[int]]

# assigning initial values to the grid
_lowercase: Matrix      			=		[
    [3, 0, 6, 5, 0, 8, 4, 0, 0],
    [5, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

# a grid with no solution
_lowercase: Matrix      			=		[
    [5, 0, 6, 5, 0, 8, 4, 0, 3],
    [5, 2, 0, 0, 0, 0, 0, 0, 2],
    [1, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]






def     a(      A       :    Matrix ,     A       :    int ,     A       :    int ,     A       :    int       )		->       bool:
					"""simple docstring"""





					for i in range(9       ):
										if grid[row][i] == n or grid[i][column] == n:
															return False

					for i in range(3       ):
										for j in range(3       ):
															if grid[(row - row % 3) + i][(column - column % 3) + j] == n:
																				return False

					return True






def     a(      A       :    Matrix       )		->       tuple[int, int] | None:
					"""simple docstring"""





					for i in range(9       ):
										for j in range(9       ):
															if grid[i][j] == 0:
																				return i, j
					return None






def     a(      A       :    Matrix       )		->       Matrix | None:
					"""simple docstring"""





					if location := find_empty_location(A       ):
										a     ,				a					     =   location
					else:
										# If the location is ``None``, then the grid is solved.
										return grid

					for digit in range(1 ,     10       ):
										if is_safe(A ,     A ,     A ,     A       ):
															a					     =   digit

															if sudoku(A       ) is not None:
																				return grid

															a					     =   0

					return None






def     a(      A       :    Matrix       )		->       None:
					"""simple docstring"""





					for row in grid:
										for cell in row:
															print(A ,     end=" "       )
										print()


if __name__ == "__main__":
				# make a copy of grid so that you can compare with the unmodified grid
				for example_grid in (initial_grid, no_solution):
								print("\nExample grid:\n" + "=" * 20)
								print_solution(example_grid)
								print("\nExample grid solution:")
								_lowercase: List[str]      			=		sudoku(example_grid)
								if solution is not None:
												print_solution(solution)
								else:
												print("Cannot find a solution.")
