|
|
@ -1,3 +1,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdbool.h> |
|
|
@ -19,6 +22,104 @@ void initializeGrid(int grid[SIZE][SIZE]); |
|
|
|
void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level); |
|
|
|
|
|
|
|
|
|
|
|
int availableLevels[3][3][SIZE][SIZE] = { |
|
|
|
{ //easy |
|
|
|
{{0, 0, 3, 0, 2, 1, 8, 0, 0}, |
|
|
|
{6, 0, 0, 0, 7, 0, 1, 3, 2}, |
|
|
|
{9, 2, 1, 5, 0, 0, 7, 6, 4}, |
|
|
|
{7, 6, 0, 3, 0, 0, 4, 0, 0}, |
|
|
|
{8, 5, 4, 1, 9, 7, 0, 0, 0}, |
|
|
|
{1, 0, 0, 4, 0, 6, 0, 0, 0}, |
|
|
|
{2, 9, 0, 8, 1, 5, 0, 0, 6}, |
|
|
|
{0, 4, 8, 2, 0, 9, 5, 0, 0}, |
|
|
|
{5, 0, 0, 7, 0, 3, 2, 0, 1}}, |
|
|
|
|
|
|
|
{{0, 0, 3, 0, 2, 1, 8, 0, 0}, |
|
|
|
{6, 0, 0, 0, 7, 0, 1, 3, 2}, |
|
|
|
{9, 2, 1, 5, 0, 0, 7, 6, 4}, |
|
|
|
{7, 6, 0, 3, 0, 0, 4, 0, 0}, |
|
|
|
{8, 5, 4, 1, 9, 7, 0, 0, 0}, |
|
|
|
{1, 0, 0, 4, 0, 6, 0, 0, 0}, |
|
|
|
{2, 9, 0, 8, 1, 5, 0, 0, 6}, |
|
|
|
{0, 4, 8, 2, 0, 9, 5, 0, 0}, |
|
|
|
{5, 0, 0, 7, 0, 3, 2, 0, 2}}, |
|
|
|
|
|
|
|
{{0, 0, 3, 0, 2, 1, 8, 0, 0}, |
|
|
|
{6, 0, 0, 0, 7, 0, 1, 3, 2}, |
|
|
|
{9, 2, 1, 5, 0, 0, 7, 6, 4}, |
|
|
|
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3, 0, 0, 4, 0, 0}, |
|
|
|
{8, 5, 4, 1, 9, 7, 0, 0, 0}, |
|
|
|
{1, 0, 0, 4, 0, 6, 0, 0, 0}, |
|
|
|
{2, 9, 0, 8, 1, 5, 0, 0, 6}, |
|
|
|
{0, 4, 8, 2, 0, 9, 5, 0, 0}, |
|
|
|
{5, 0, 0, 7, 0, 3, 2, 0, 0}} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void startSudoku() { |
|
|
|
int grid[SIZE][SIZE]; |
|
|
|
selected_level = 0; |
|
|
@ -95,6 +196,7 @@ void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { |
|
|
|
printf("Level is getting initialized"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|