Browse Source

Commit 7 code

main^2
Lucas Heil 11 months ago
committed by Peter Wiebe
parent
commit
17b16df1d9
  1. 102
      src/main/c/sudoku.c

102
src/main/c/sudoku.c

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

Loading…
Cancel
Save