array_validation

array_validation

Core validation utilities for Sudoku array units.

This module provides generic validation functionality for checking whether one-dimensional array-like objects represent valid Sudoku units. Higher-level validation functions for rows, columns, and subgrids rely on the functions defined here.

Functions

Name Description
array_validation Validate whether an array represents a valid Sudoku unit.

array_validation

array_validation.array_validation(unit)

Validate whether an array represents a valid Sudoku unit.

This function checks whether the provided array corresponds to a valid Sudoku unit (row, column, or 3x3 square). A valid unit must contain unique integers from 1 to 9.

This function serves as the core validation logic for all Sudoku unit checks. Higher-level validation functions (e.g., row, column, square) are expected to transform their respective inputs into a one-dimensional array and delegate validation to this function.

Parameters

Name Type Description Default
unit array-like of shape (9,) A one-dimensional array representing a Sudoku unit. The array must contain numeric values. required

Returns

Name Type Description
bool True if the array represents a valid Sudoku unit according to Sudoku rules; False otherwise.

Raises

Name Type Description
ValueError If the input cannot be interpreted as a one-dimensional array of length 9.

Notes

  • A valid Sudoku unit contains no duplicate values among the digits 1 through 9.
  • This function does not modify the input array.

Examples

>>> array_validation([5, 3, 4, 6, 7, 8, 9, 1, 2])
True
>>> array_validation([5, 3, 0, 6, 7, 8, 9, 1, 5])
False