Sudoku web service
- download source code here
- build and run test
GOPATH=`pwd` make
- Path:
/sovler
- solve a sudoku puzzle
- Method:
GET
- Parameters:
puz=
serialized_sudoku_puzzle - Returns:
{puz: requested_puzzle, solutions: solution_array}
solution_array
: an array with all solutions,- or
null
when therequested_puzzle
is invalid.
- Method:
- Path:
/checker
- check a sudoku puzzle is valid or not
- Method:
GET
- Parameters:
puz=
serialized_sudoku_puzzle - Returns:
{puz: requested_puzzle, valid: [true|false], blanks: number_of_blanks}
- Method:
- Path:
/puzzles
- create a new sudoku puzzle
- Method:
POST
- Parameters:
puz=
serialized_sudoku_puzzlelevel=
puzzle_leveldate=
YYYYmmDD, Optional
- Returns:
{result: puzzle, status:[created|existed|invalid]}
, puzzle is:{puz: serialized_sudoku_puzzle, date: release_date, level: n}
- or
null
, ifstatus
isinvalid
- Method:
- query some sudoku puzzle
- Method:
GET
- Parameters:
date=
YYYYmmDD, request a sudoku puzzle released on a specificdate
level=
n, level of a puzzle, default value0
rand=
[0|1], Optional, request a random sudoku puzzle- requested with
rand=1
, severr will ignoredate
parameter
- requested with
- Returns:
{result: puzzle_array, status:[found|notfound]}
, element ofpuzzle_array
:{puz: serialized_sudoku_puzzle, date: release_date, level: n}
- or
null
, ifstatus
isnotfound
- Method:
- update an exist sudoku puzzle
- Method:
PATCH
- Parameters:
puz=
serialized_sudoku_puzzle,new=
serialized_sudoku_puzzle,
- Returns:
{result: puzzle, status:[updated|notfound|existed|invalid]}
, puzzle is:{puz: serialized_sudoku_puzzle, date: release_date, level: n}
- or
null
, ifstatus
isinvalid
- Method:
- delete an exist sudoku puzzle
- Method:
DELETE
- Parameters:
puz=
serialized_sudoku_puzzle
- Returns:
{result: puzzle, status:[deleted|notfound]}
, puzzle is:{puz: serialized_sudoku_puzzle, date: release_date, level: n}
- or
null
, ifstatus
isnotfound
- Method:
- a row scaned one line string
- use
0
to represent emtpy cell
1 | 6 | 3 | 9 | 2 | 7 | 8 | 4 | 5 |
---|---|---|---|---|---|---|---|---|
8 | 9 | 4 | 3 | 5 | 6 | 1 | 7 | 2 |
7 | 2 | 5 | 4 | 1 | 8 | 9 | 6 | 3 |
5 | 8 | 1 | 7 | 6 | 2 | 4 | 3 | 9 |
2 | 3 | 6 | 8 | 9 | 4 | 5 | 1 | 7 |
4 | 7 | 9 | 5 | 3 | 1 | 6 | 2 | 8 |
6 | 1 | 7 | 2 | 8 | 5 | 3 | 9 | 4 |
9 | 4 | 8 | 1 | 7 | 3 | 2 | 5 | 6 |
3 | 5 | 2 | 6 | 4 | 9 | 7 | 8 | 1 |
It's a full filled sudoku, will serialized as:
163927845894356172725418963581762439236894517479531628617285394948173256352649781
read more about sudoku: https://en.wikipedia.org/wiki/Sudoku