![]() |
.. (לתיקייה המכילה) | |
Q4- What should initSpot do? | |
initSpot is given to you. No need to implement it. |
Q4- Why do we connect the rows, the columns and the squares? | |
Every spot in the puzzle belongs to a (horizontal) row and a (vertical) column, as well as to one single 3x3 square (which we call "square" for short). At the beginning, some of the spots carry a single-digit number between 1 and 9. The problem is to fill the missing spots with digits in such a way that every number between 1 and 9 appears exactly once in each row, in each column, and in each square. We represent the Sudoku puzzle as a simple list of 81 digits. At the beginning, the list is partially instantiated. During the process, all the elememts of the list get instantiated with digits. We are going to treat each spot as a Prolog term spot(X,R,C,S) where X is the number to put into the field, R is the row, C the column, and S the square the field belongs to. R, C, and S are lists which represent the respective number sets. We connect the related spots. The spots that their X value effect one another. We place constraints so that all spots in a row will have the same R Variable. We place constraints so that all spots in a column will have the same C Variable. We place constraints so that all spots in a square will have the same S Variable. |
Why do we get "Singleton variables" warning? | |
The warning is shown when you use a named variable once. Use _ wild card instead. |
Q4- What does ConnectBands do? | |
connectSq- connects the S variable of a square. connectBand- uses connectSq and connects 3 squares (a vertical band on the board sized 3x9). connectBands- uses connectBand and connects 3 bands (that why we connect all squares in the board). Note that we don't connect between squares. Just all spots inside each square. |
Prolog: Is it OK if i get the same answer several times? | |
Yes, as long as the answer is correct. |
Correction to Goldbach.java: | |
Please change the line: if (p.add(q) == i) With: if ((p.add(q)).compareTo(i) == 0) |