Anda di halaman 1dari 23

OVERVIEW ON ~C

WHAT SUDOKU IS!


A deceptively simple game of logic, Sudoku is puzzling players all over world. Whether you're new to this fun and addictive game or you re already hooked, we have everything you need to get started playing today! Many of the games with unique twists having the same feature as Sudoku are also available. Experiment with the different Sudoku games and discover these exciting variations!

9x9 Matrix The format of Sudoku

An example

BASIC RULES
We can use only the digit 1 to 9. There is really only one rule to Sudoku: Fill in the game board so that the numbers 1 through 9 occur exactly once in each row, column, and 3x3 box.

GOALS
Your initial game board will consist of several numbers that are already placed. Those numbers cannot be changed. Your goal is to fill in the empty squares following the simple rule above.

Figure 1

Solution

Problems

ALGORITHM
Define a matrix of 9 row & 9 column. int m[9][9]; Now place the no. on the right place as input For the empty place we have to assign 0.

Formation of matrix m[9][9]={{0,0,4,3,0,1,7,0,0} {0,8,0,0,4,0,0,9,0} {5,0,0,0,0,0,0,0,1} {8,7,0,0,0,0,0,1,3} {0,0,0,7,0,9,0,0,0} {2,5,0,0,0,0,0,7,8} {3,0,0,0,0,0,0,0,7} {0,4,0,0,7,0,0,5,0} {0,0,4,3,0,1,7,0,0}}

Traverse for the 0 element for(i=0;i<9;i++) for(j=0;j<9;i++) if(m[i][j]==0)

Check which no's are not possible for that cell. ** Row wise checking ** { for(k=1;k<=9;k++) { a=0; ar[]=NULL; for(l=0;l<9;l++) { if(m[l][j]==k&&m[l][j]!=0) { c++; ar[a++]=k; **go back to the for loop of k** } }

** Column wise checking ** for(n=0;n<9;n++) { if(m[i][n]==k&&m[i][n]!=0) { c++; ar[a++]=k; **go back to the for loop of k** } }

** 3x3 box wise checking ** ir=i/3; cr=j/3; for(ir=ir*3;ir<(i/3)+3;ir++) for(cr=cr*3;cr<(j/3)+3;cr++) { if(m[ir][cr]==k&&m[ir][cr]!=0) { c++; ar[a++]=k; } } }

If count of impossible no is eight then place the 9th no replacing 0. if(c==8) { b=0; for(p=1;p<=9;p++) { if(ar[b]!=p) m[i][j]==ar[b]; b++; } } Search for next 0 element from the matrix & do the same.

When checking pointer for the 0 element comes to the m[8][8] position, pointer must go to the m[0][0]. cx=0; for(ix=0;ix<9;ix++) for(jx;=0;jx<9;jx++) if(m[ix][jx]!=0) cx++; if(i==8&&j==8&&cx==0) { i=0; j=0; }

CONCLUSION
Each Sudoku puzzle has one unique solution. The difficulty varies depending on how many numbers you are given to start with - the more numbers usually the easier the puzzle. Puzzles also tend to be symmetrical.

Sudoku, originally a Japanese game however some will say Chinese. Born at the 18th century, (about 200 year ago) that just recently stormed the world and can be seen everywhere (good things takes time). It can be played anywhere and any time and can be a great time killer , but should not be addicted. The Sudoku is a puzzle yet a sophisticated one that can keep you intrigued for long time.

The qualifications needed to play Sudoku puzzle are none that is why any one can play it, how ever - patience, time and concentration can be in hand for addicts. It s a fun puzzle dealing with numbers, but it s not Math!! No basic knowledge needed and any one can play it - that is why it became a game for the whole family.

Perfection will come with practice. Sudoku is proposed for the next Cyber world cup. Every year in technical competition in China and Japan Sudoku is a very popular to all the competitor. So we can use this kind of software to solve this type of problems quickly.

Anda mungkin juga menyukai