write code to initialise the sudoku board
This commit is contained in:
@@ -8,6 +8,12 @@
|
|||||||
|
|
||||||
#include "util/intdef.h"
|
#include "util/intdef.h"
|
||||||
|
|
||||||
|
void sudoku_init(u16 *board) {
|
||||||
|
for (uint i = 0; i < SUDOKU_DEPTH_2; i++) {
|
||||||
|
board[i] |= SUDOKU_ALL & -!board[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sudoku_solve_step(u16 *board) {
|
void sudoku_solve_step(u16 *board) {
|
||||||
u16 bmask[SUDOKU_DEPTH_2]; // board mask
|
u16 bmask[SUDOKU_DEPTH_2]; // board mask
|
||||||
memcpy(bmask, board, SUDOKU_DEPTH_2 * 2);
|
memcpy(bmask, board, SUDOKU_DEPTH_2 * 2);
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
#include "util/intdef.h"
|
#include "util/intdef.h"
|
||||||
|
|
||||||
#define SUDOKU_DEPTH 9 // defines the "depth" of the puzzle.
|
#define SUDOKU_DEPTH_SQRT 3
|
||||||
#define SUDOKU_DEPTH_2 (SUDOKU_DEPTH * SUDOKU_DEPTH) // computes how many squares there are
|
#define SUDOKU_DEPTH (SUDOKU_DEPTH_SQRT * SUDOKU_DEPTH_SQRT)
|
||||||
|
#define SUDOKU_DEPTH_2 (SUDOKU_DEPTH * SUDOKU_DEPTH)
|
||||||
|
|
||||||
/* bitmask */
|
/* bitmask */
|
||||||
enum sudoku_bitmask {
|
enum sudoku_bitmask {
|
||||||
@@ -18,8 +19,12 @@ enum sudoku_bitmask {
|
|||||||
SUDOKU_7 = 0x040,
|
SUDOKU_7 = 0x040,
|
||||||
SUDOKU_8 = 0x080,
|
SUDOKU_8 = 0x080,
|
||||||
SUDOKU_9 = 0x100,
|
SUDOKU_9 = 0x100,
|
||||||
|
SUDOKU_ALL = 0x01FF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* initialises the sudoku board to `SUDOKU_ALL`. (if the tile is empty) */
|
||||||
|
void sudoku_init(u16 *board);
|
||||||
|
|
||||||
/* TODO: write documentation */
|
/* TODO: write documentation */
|
||||||
void sudoku_solve_step(u16 *board);
|
void sudoku_solve_step(u16 *board);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user