Alex Holland - Technical Challenge Submission #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sudoku Implementation
The Go implementation introduces a Sudoku solver that combines cross-hatching and recursive backtracking for improved performance. It efficiently scans rows and columns to identify potential values, employing systematic prioritization of almost-filled elements for enhanced solving. The solver validates board dimensions and numbers, using recursive backtracking to find a solution. The
printBoard
function aids in displaying the solved board in a readable json format.Test Cases
The Sudoku solver test suite covers a range of scenarios. It ensures correct solutions for standard puzzles, including those with incomplete rows, columns, and blocks. Additionally, it checks the solver's ability to handle puzzles with a single empty cell, already completed puzzles, and challenging ones like the world's hardest Sudoku by Arto Inkala. The suite also assesses robustness by testing invalid board dimensions, layouts, and numbers, providing comprehensive validation of the solver's functionality.
Instructions
Execute the tests:
go test
Run the program and display output:
go run sudoku.go
Component Name
sudoku.go
sudoku_test.go