A simple Sudoku REST API (written in Go) designed to solve and generate Sudoku puzzles with customizable grid dimensions as well as subgrid dimensions.
- Go 1.16 or later. See the install instructions for Go.
Usage:
sugoku [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
start Start a sudoku server
Flags:
-h, --help help for sugoku
Use "sugoku [command] --help" for more information about a command.
We will use the grid below as input for the example.
1 . | . 4
. . | 1 .
--------------
2 . | . .
4 . | 2 .
In order to solve a sudoku puzzle:
- Send a POST request to
/sudoku
with the puzzle injson
format in the body, and optionally you may set the query parameterpretty=true
for a human readable output.
curl -X POST http://localhost:7007/sudoku?pretty=true -d '{"size":4,"partitionWidth":2,"partitionHeight":2,"grid":[[49,46,46,52],[46,46,49,46],[50,46,46,46],[52,46,50,46]]}'
- Server responds with a valid solution:
1 2 | 3 4
3 4 | 1 2
--------------
2 1 | 4 3
4 3 | 2 1
- Done!
In order to generate a 9x9 hard sudoku puzzle:
- Send a GET Request to
/sudoku
endpoint with the following query parameterssize=9
,partitionWidth=3
,partitionHeight=3
and optionally addpretty=true
for a human readable output
curl 'http://localhost:7007/sudoku?pretty=true&size=9&partitionWidth=3&partitionHeight=3&level=hard'
- Server responds with a human readable output of the puzzle
1 . 7 | . . . | . . .
. . . | 3 8 . | . . .
3 . . | . 9 . | . . 5
-----------------------------
. 1 . | . . 2 | . . .
. . 2 | . . . | . . .
. . . | . 1 . | 7 . .
-----------------------------
2 . 1 | . . . | . . .
5 . . | . 3 . | . . .
6 . . | . . 1 | . . .
- Done!
- Add more unit tests
Improve errors handling in the route handlersImprove request loggingAdd a Sudoku puzzle generator endpoint- Add authentication?
- Support HTTPS?
- Build a Front End
- ...