NMX.SudokuGen.Library 1.0.0

dotnet add package NMX.SudokuGen.Library --version 1.0.0
                    
NuGet\Install-Package NMX.SudokuGen.Library -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NMX.SudokuGen.Library" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NMX.SudokuGen.Library" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NMX.SudokuGen.Library" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NMX.SudokuGen.Library --version 1.0.0
                    
#r "nuget: NMX.SudokuGen.Library, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NMX.SudokuGen.Library@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NMX.SudokuGen.Library&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NMX.SudokuGen.Library&version=1.0.0
                    
Install as a Cake Tool

Sudoku Gen Library

sudoku C# library dll

© 2024-2026 New Media XP. Licensed under the MIT License.
| website | email |


Description

A library written in C# to generate and solve sudoku puzzles.


API

using NMX.SudokuGen.Library.Core;

Sudoku a_sudoku = Sudoku.Create(3, 40);            // rank 3 (9×9), up to 40 blanks
Sudoku a_solved = Sudoku.Solve(a_sudoku.Puzzle);   // unique solution guaranteed
string a_code   = Utility.GetPuzzleCode(a_sudoku.Puzzle);

Sudoku

Immutable puzzle/solution pair. Grids are flat, row-by-row lists of squares values, 0 = blank.

Methods
Member Signature Description
Create static Sudoku Create(int rank, int blanks, bool exhaustive = false) New random puzzle with a unique solution. blanks = maxBlanks (-1) requests as many as possible. exhaustive skips the search budget for an exact blank count (can run very long at high ranks).
Create static Sudoku Create(int rank, int blanks, int seed, bool exhaustive = false) Seeded create — the same seed reproduces the same puzzle.
Solve static Sudoku Solve(IReadOnlyList<int> puzzle) Solves a puzzle, rank inferred from its length. Throws if the input is invalid, conflicting, or has no unique solution.
Shuffle Sudoku Shuffle() Returns an equivalent variant (same rank, difficulty and blank count, different look). The original is untouched.
Shuffle Sudoku Shuffle(int seed) Seeded shuffle.
FindConflicts Conflict FindConflicts(int[] board, int index) Which units the value at index repeats in. A blank (0) never conflicts.
Properties
Member Type Description
Puzzle IReadOnlyList<int> The puzzle grid, 0 = blank.
Solution IReadOnlyList<int> The unique completed solution.
Removed int Actual blank count (can be less than blanks when more would break uniqueness).
rank int Segment size, 2 (4×4) to 5 (25×25).
rows int Squares per row, column and segment (rank²).
squares int Total squares (rows²).
remove int Requested blank count (the blanks argument to Create).
minRank / maxRank const int Allowed rank bounds, 2 and 5.
maxBlanks const int Sentinel for Create's blanks: -1 means "as many as possible".

Conflict

[Flags] enum, returned by FindConflicts.

Value Meaning
None No conflict.
Row Value repeats in the row.
Column Value repeats in the column.
Segment Value repeats in the segment (box).

A square that is rule-clean but still wrong (board[i] != Solution[i]) returns None — compare against Solution to catch those.

Utility

Member Signature Description
GetPuzzleCode static string GetPuzzleCode(IReadOnlyList<int> grid) Encodes a grid as a puzzle code: one char per square (0 blank, 1-9, A = 10…), . between rows.
GetPuzzleArr static int[] GetPuzzleArr(string code) Parses a puzzle code back into a grid array; unrecognised characters are ignored.

Also exposes general array/bit helpers used internally — Copy, Same, Count, Swap2, Init, InitRandom, PopCount.

Notes

  • Thread safety — no shared mutable state. Instances are independent, so parallel Create / Solve / Shuffle calls are safe. For background work, wrap calls in Task.Run at the call site.

Details

  • Released on 3 April 2025

  • Dependencies

    • .Net Standard 2.1
  • Used in

  • Downloads


Contact


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 123 6/24/2026