A Sudoku-like number puzzle game where players must select cells in a grid to match target sums for each row and column.
- The game board is a square grid of size NxN (where N is between 3 and 9)
- Each cell contains a number between 1 and 9
- Players must select cells in each row and column to match the target sums
- A cell can be selected or deselected
- The game is won when the sum of selected cells in each row and column matches their respective target sums
The game offers four difficulty levels:
-
Easy:
- Each row and column has only one possible combination to reach the target sum
- Target sums are achieved by selecting a single cell or a small number of cells
- Perfect for beginners
-
Medium:
- Each row and column has 2-3 possible combinations to reach the target sum
- Target sums require selecting multiple cells
- Good for players who understand the basic mechanics
-
Hard:
- Each row and column has 3-5 possible combinations to reach the target sum
- Target sums require selecting multiple cells with overlapping possibilities
- Challenging for experienced players
-
Very Hard:
- Each row and column has 5+ possible combinations to reach the target sum
- Target sums require selecting multiple cells with many overlapping possibilities
- For expert players seeking maximum challenge
GET /game/{size}/{difficulty}
Parameters:
size: Board size (3-9)difficulty: Difficulty level (easy, medium, hard, very-hard)
Response:
{
"board": [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
],
"targetRowSums": [6, 15, 24],
"targetColSums": [12, 15, 18],
"boardSize": 3,
"difficulty": "medium"
}go run main.goThe server will start on port 8080 by default.
- Create a new 3x3 easy game:
curl http://localhost:8080/game/3/easy- Create a new 5x5 medium game:
curl http://localhost:8080/game/5/medium- Create a new 9x9 very hard game:
curl http://localhost:8080/game/9/very-hard{
"board": [
[7, 4, 2, 8, 1],
[3, 9, 5, 6, 4],
[8, 2, 7, 1, 9],
[5, 1, 4, 3, 7],
[2, 6, 9, 5, 8]
],
"targetRowSums": [15, 18, 16, 13, 20],
"targetColSums": [17, 16, 18, 14, 17],
"boardSize": 5,
"difficulty": "medium"
}- Invalid board size:
{
"error": "Invalid board size. Size must be between 3 and 9"
}- Invalid difficulty level:
{
"error": "Invalid difficulty level. Must be one of: easy, medium, hard, very-hard"
}- Request a new game board using the API
- Present the board to the player
- Let the player select/deselect cells
- Calculate sums for each row and column
- Compare with target sums to check if the solution is correct
- The server handles requests concurrently
- Each request generates a unique board
- All generated boards are guaranteed to have at least one valid solution
- Target sums are always achievable using the numbers in the grid
- The API response includes all necessary information to play the game
- Board generation time should be under 100ms
- Solution validation time should be under 100ms
- The game must have at least one valid solution
- Target sums must be achievable using the numbers in the grid