Table of Contents

Class Solver

Namespace
NonoSharp
Assembly
NonoSharp.dll

A static class to solve Nonogram puzzles, or determine if they can be solved.

public static class Solver
Inheritance
Solver
Inherited Members

Remarks

The Solver will not make any guesses, meaning that puzzles with a valid and unique solution that might require more advanced logical deduction, or guesses in any other form, might be rejected. Puzzles without one unique answer, are rejected.
Note that the runtime of solving a puzzle grows exponentially with its size. For a quick runtime, keep puzzles small (~25x25). There are, however, no restrictions on the methods regarding puzzle size.

Methods

IsSolvable(Nonogram)

Determines whether the puzzle in nonogram can be solved.

public static bool IsSolvable(Nonogram nonogram)

Parameters

nonogram Nonogram

The Nonogram instance to check solvability for.

Returns

bool

true if the puzzle can be solved, false otherwise.

IsSolvable(Nonogram, out HashSet<CellPosition>?)

Determines whether the puzzle in nonogram can be solved.

public static bool IsSolvable(Nonogram nonogram, out HashSet<CellPosition>? solution)

Parameters

nonogram Nonogram

The Nonogram instance to check solvability for.

solution HashSet<CellPosition>

The solution HashSet if nonogram is solvable. null if the puzzle is not solvable.

Returns

bool

true if the puzzle can be solved, false otherwise.

IsSolvable(int, int, Clues[], Clues[])

Determines whether the puzzle constructed from the given dimensions and clues can be solved.

public static bool IsSolvable(int width, int height, Clues[] columnClues, Clues[] rowClues)

Parameters

width int

Width of the puzzle to solve.

height int

Height of the puzzle to solve.

columnClues Clues[]

Column clues (usually shown on the top of the puzzle) for this puzzle.

rowClues Clues[]

Row clues (usually shown on the right of the puzzle) for this puzzle.

Returns

bool

true if the puzzle can be solved, false otherwise.

Exceptions

ArgumentException

Thrown when the lengths of columnClues and rowClues do not match width or height respectively.

ArgumentOutOfRangeException

Thrown when width or height are non-positive.

IsSolvable(int, int, Clues[], Clues[], out HashSet<CellPosition>?)

Determines whether the puzzle constructed from the given dimensions and clues can be solved.

public static bool IsSolvable(int width, int height, Clues[] columnClues, Clues[] rowClues, out HashSet<CellPosition>? solution)

Parameters

width int

Width of the puzzle to solve.

height int

Height of the puzzle to solve.

columnClues Clues[]

Column clues (usually shown on the top of the puzzle) for this puzzle.

rowClues Clues[]

Row clues (usually shown on the right of the puzzle) for this puzzle.

solution HashSet<CellPosition>

The solution HashSet if the puzzle is solvable. null if the puzzle is not solvable.

Returns

bool

true if the puzzle can be solved, false otherwise.

Exceptions

ArgumentException

Thrown when the lengths of columnClues and rowClues do not match width or height respectively.

ArgumentOutOfRangeException

Thrown when width or height are non-positive.

Solve(Nonogram)

Solves the puzzle of Nonogram instance nonogram in-place.

public static HashSet<CellPosition> Solve(Nonogram nonogram)

Parameters

nonogram Nonogram

Puzzle to solve.

Returns

HashSet<CellPosition>

The solution in a HashSet of CellPositions.

Remarks

If the given puzzle is not solvable, the returned solution will be incomplete. To ensure a complete solution, use IsSolvable(Nonogram, out HashSet<CellPosition>?).