<filename>python/random_sudoku.py
#!/usr/bin/env python3

# Provider for tests for sudoku parsers and solvers in python

from argparse import ArgumentParser, Namespace
from random import sample
from typing import List

"""
    random_board,
    pprint_board former  board_format come from https://github.com/cclauss/Ten-lines-or-less/blob/master/sudoku_revisited.py 
"""
def random_board(cells) -> List[List[int]]:
    return [sample(range(1, cells + 1), cells) for i in range(cells)]

def pprint_board(board, cells) -> None:
    s = f"\n|\xa0{['-']*cells}+\n"
    b = s.replace("|", "-")
    print(b + s.join(" | ".join(str(y) for y in x) for x in board) + b)

def main(args=None) -> None:
    matrixSize = args.cells
    # if matrixSize < 2:
    #     raise ValueError(f"cant produce board with those dimensions -> --cells={matrixSize}")
    board  = random_board(matrixSize)
    print(board)
    # pprint_board(board, matrixSize)


if __name__ == "__main__":
    parser: ArgumentParser = ArgumentParser()
    parser.add_argument("--cells", type=int, default=9, help="define the size of the matrix")
    args: Namespace = parser.parse_args()
    main(args=args)


