2. Question
•
•
•
나머지 빈 칸을 채우는 방식은 다음과 같다.
(1) 각각의 가로줄과 세로줄에는 1부터 9까지의 숫자가 한 번씩만 나타나야 한다.
(2) 굵은 선으로 구분되어 있는 3x3 정사각형 안에도 1부터 9까지의 숫자가 한 번씩만 나타나야 한다.
위의 예의 경우, 첫째 줄에는 1을 제외한 나머지 2부터 9까지의 숫자들이 이미 나타나 있으므로 첫째 줄 빈칸에는 1
이 들어가야 한다.
또한 위쪽 가운데 위치한 3x3 정사각형의 경우에는 3을 제외한 나머지 숫자들이 이미 쓰여 있으므로 가운데 빈 칸
에는 3이 들어가야 한다.
8. Algorithm(Cont’d)
•
Remain issue
–
–
–
–
–
–
–
In an order of visit among the candidates makes an issue
As following example we got the candidates 2, 7 at line 5
At first, 2 is put at the col 2.
In this case 2 makes an duplicate condition in the vertical line
So, we try to put 7 at the position.
And 2 will not be considered.
So, we will reconsider during return to the first recursion.
035469278
782105609
060278135
321046897
804913506
596820413
917652080
603701952
258394760
9. Core methods
• makeSdoku(int)
–
–
–
–
각 행에서 아직 선택되지 않은 후보들을 찾아서
빈 칸에 놓아 보고
중복 조건에 위배되면
조건을 만족할 때 까지 다른 빈 칸에 놓는 동작을 반복
• getCandidates(int)
– 아직 선택되지 않은 후보들을 찾음
• getVacancyCol(int)
– 빈 칸을 찾음
• isDuplicate(int, int, int)
– 중복 조건을 검토