Browse Source

Commit 6 code

remotes/origin/Lucas
Lucas Heil 11 months ago
parent
commit
6534e2e596
  1. 29
      src/main/c/sudoku.c

29
src/main/c/sudoku.c

@ -15,6 +15,9 @@ int selected_level;
void startSudoku(); //is instead of main void startSudoku(); //is instead of main
void availableLevelsFunction(int difficulty); void availableLevelsFunction(int difficulty);
void selectLevel(int grid[SIZE][SIZE]); void selectLevel(int grid[SIZE][SIZE]);
void initializeGrid(int grid[SIZE][SIZE]);
void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level);
void startSudoku() { void startSudoku() {
int grid[SIZE][SIZE]; int grid[SIZE][SIZE];
@ -64,17 +67,39 @@ void selectLevel(int grid[SIZE][SIZE]) {
level = level_select[0] - '0'; // Convert the first character to an integer level = level_select[0] - '0'; // Convert the first character to an integer
if ((level >= 1 && level <= 3) && level_select[1] == '\0') { if ((level >= 1 && level <= 3) && level_select[1] == '\0') {
printf("Input is correct");
selected_level = level;
level--; // Adjust to 0-based index
generateSudoku(grid, difficulty, selected_level);
break; break;
} else { } else {
printf("Invalid input. Please enter a number between 1 and 3.\n"); printf("Invalid input. Please enter a number between 1 and 3.\n");
} }
} }
} }
void initializeGrid(int grid[SIZE][SIZE]) {
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
grid[i][j] = EMPTY;
}
}
}
void generateSudoku(int grid[SIZE][SIZE], int difficulty, int level) {
initializeGrid(grid);
printf("Level is getting initialized");
}

Loading…
Cancel
Save