-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
42 lines (38 loc) · 1.2 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include "common.h"
#include "sudoku_solver.h"
void print_welcome_message(void)
{
printf("\n\tWelcome to the Sudoku solver!\n");
printf("\nIt tries to solve sudoku by using the following techniques:\n\n");
printf("\t1. Naked single detection\n\t2. Hidden single detection\n\t3. Naked double detection\n\n");
printf("Enter a VALID sudoku table:\n");
printf("A VALID sudoku table satisfies the following criteria\n");
printf("\t- It is a 9*9 table\n");
printf("\t- A cell that is yet to be filled is represented by 0\n");
printf("\t- A cell only has valid entries [0, 9]\n");
}
void get_table(unsigned int table[TABLE_ORDER_MAX][TABLE_ORDER_MAX])
{
for (size_t row=0; row<TABLE_ORDER_MAX; row++)
{
for (size_t col=0; col<TABLE_ORDER_MAX; col++)
{
scanf("%u", &table[row][col]);
}
}
}
void print_solution(unsigned int table[TABLE_ORDER_MAX][TABLE_ORDER_MAX])
{
printf("\nSolved table:\n");
print_table(table);
printf("Note: Solutions might be partial if the table cannot be solved using techniques mentioned before.\n");
}
int main(void)
{
unsigned table[TABLE_ORDER_MAX][TABLE_ORDER_MAX] = {0};
print_welcome_message();
get_table(table);
solve_sudoku(table);
print_solution(table);
}