You're reading the documentation for a development version. For the latest released version, please have a look at master.
queens_solver.main
Functions
|
Run the complete Queens puzzle solving pipeline. |
|
Print a formatted Queens puzzle solution to the terminal. |
|
Format an integer value with optional terminal coloring. |
Module Contents
- queens_solver.main.run(*args, **kwargs)[source]
Run the complete Queens puzzle solving pipeline.
Parses the board, solves it with integer linear programming, validates the solution in-browser, then prints the result.
- Parameters:
*args – Positional arguments forwarded to
parse_queens_game.**kwargs – Keyword arguments forwarded to
parse_queens_game.
- Return type:
None
- queens_solver.main.print_queens_solution(layout, solution)[source]
Print a formatted Queens puzzle solution to the terminal.
Queen cells are represented as negative values for conditional color formatting via
numpy.printoptionswith a custom integer formatter.- Parameters:
layout (scipy.sparse.csr_matrix) – Sparse matrix of the puzzle layout. Each entry holds the integer color ID of a cell.
solution (numpy.ndarray) – Dense binary array.
1indicates a queen,0an empty cell.
- Return type:
None
- queens_solver.main.mark_ndarray(x, marker='*', offset=0)[source]
Format an integer value with optional terminal coloring.
Negative values are highlighted with
marker; positive values are printed normally. The displayed value is shown as its absolute value plusoffset.- Parameters:
x (int) – Integer value to format.
marker (str) – Character used to mark queen positions. Defaults to
"*".offset (int) – Value added to the displayed absolute value. Defaults to
0.
- Returns:
Formatted string with ANSI color escape sequences.
- Return type:
str