GROUP MEMBERS :
NAME- STUDENT ID
MD Ahsan Habib – 180211
Mahbub E Elahi – 180212
Sk. Wasiqul Hoque – 180219
Al Afiat Emon – 180231
WHAT IS SUDOKU ?
Sudoku is a logic based combinatorial number-placement puzzle . The objective is to fill a 9×9 box with digits so that each column, each row, and each of the nine 3×3 subgrids that compose the grid (also called “boxes”, “blocks”, or “regions”) contains all of the digits from 1 to 9. We provide a partially completed grid, which has a single solution.
HOW TO PLAY
· There is only one valid solution to each Sudoku puzzle. The only way the puzzle can be considered solved correctly is when all 81 boxes contain numbers and the other Sudoku rules have been followed.
· When you start a game of Sudoku, some blocks will be pre-filled for you. You cannot change these numbers in the course of the game.
·Each column must contain all of the numbers 1 through 9 and no two numbers in the same column of a Sudoku puzzle can be the same.
· Each row must contain all of the numbers 1 through 9 and no two numbers in the same row of a Sudoku puzzle can be the same.
· Each block must contain all of the numbers 1 through 9 and no two numbers in the same block of a Sudoku puzzle can be the same.
INTERPRETATION OF THE CODE
We made this project using C programming language . We implemented the graphics.h library header function which wasn’t built-in with codeblocks . We downloaded and learned how to use it from https://learn24bd.com/how-to-enable-graphics-h-in-codeblocks .
First we used the initialwindow function () for controlling the size/bar/exit sign. Then we set the text color in graphics window . After that we used the ‘settextstyle()’ function to control the size and font of the text. We used ‘outtextxy()’ function to control and write the desired text in the graphics window. Then we used the ‘getch()’ function. Finally we used ‘cleardevice()’ function to format the graphics window. On the fresh window we set the background color using ‘setfillstyle()’ , ‘setbkcolor()’and ’floodfill()’ . Then we created 81 boxes by using ‘rectangle()’ function inside 9 for loops. Then we separated the 3X3 boxes by using a different color ‘line()’ function . We read a sample sudoku problem from a file and solution then stored them in 2 2D array one for the problem and one for the solution. Then we inserted the values of the unsolved problem array in each box of the graphics window by using ‘sprintf()’ and ‘outtextxy()’ function. Mainly we used ‘sprintf()’ function to convert the integer type into character type because ‘outtextxy()’ can only take character type values. We used red color in ‘setcolor()’ function to indicate the unsolved values (in this case 0) and we used green color in ‘setcolor()’ function to indicate other given values.
Now we started solving the problem. When the player wants to rewrite the an unsolved value all he needs to do to right click that certain box to rewrite the value of the box. We took the answers in the console from the player by using ‘scanf ()’ function and placed them in the unsolved boxes in the graphic window. Then we match the player’s answer with actual answer. If the answer is correct then it turns green. We did it by using ‘setcolor ()’ function. If the answer is wrong then it turns red so that the player can understand that his answer is wrong… One by one the player will fill up all the unsolved boxes. If his solution is correct then program will show him “WELL DONE”. The player can play the game once again by pressing 0. We use ‘goto’ function to do that.
ALL THE CODE AND PIC ARE GIVEN BELOW: