From 17b16df1d9fc60764505c01c9e2cc9b701d81fff Mon Sep 17 00:00:00 2001 From: Lucas Heil Date: Wed, 7 Feb 2024 17:13:03 +0100 Subject: [PATCH] Commit 7 code --- src/main/c/sudoku.c | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/src/main/c/sudoku.c b/src/main/c/sudoku.c index 87089c0..dcdfb7b 100644 --- a/src/main/c/sudoku.c +++ b/src/main/c/sudoku.c @@ -1,3 +1,6 @@ + + + #include #include #include @@ -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}, + {7, 6, 0, 3, 0, 0, 4, 0, 0}, + {8, 5, 4, 1, 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}, + {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}}, + + {{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() { int grid[SIZE][SIZE]; selected_level = 0; @@ -93,6 +194,7 @@ void initializeGrid(int grid[SIZE][SIZE]) { void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) { initializeGrid(grid); printf("Level is getting initialized"); + }