Re: SWI Prolog Sudoku



JJ <rompeqk@xxxxxxxxxxx> wrote:
Hi, i'm new to prolog and i have to write a sudoku solver 2x2 and 9x9
for a class as a final project, can anyone tell me how do i do
that???? i read a tutotial online but i doen'st even tell me how to
make the grid or the rows and columns or how to put the values in it.
I got some code from the internet but everytime i try to run int it
gives me this error: Undefined procedure: domain/3. So is either i
don't know how to run it or there's something wrong with the file.


Sudoku problems are probably best solved by greedy methods.
I posit that's why thery're so popular for human players. :)



The method I've used some places is to take the puzzle and determine
which square has the least number of possibilities left. In many cases
there is only 1 possible digit that can go in a square.
Fill it in and loop back to start.


If you find a square with no possible digit youhave an insoluble Sudoku.
If it's due to one of your own guess then backgtrack.


If you find a square has more than 1 possible digit as
a solution, take a stab and choose one. Loop back to start.


A simplified version using no backtracking is simply restart the
whole solver if you end up with a square with no possible choice left.
This is like a "backtrack to the top" method. IMX it turns out to
offer the fastest possible solver on underpowered h/w like MP3 players
and cellphones. :)
.



Relevant Pages

  • Re: Enigma 1441 - The missing link
    ... accepted for publication. ... to the original puzzle. ... I have a feeling this implies that we have to find a digit for the? ... I try to find a solution that doesn't have 1 in that square. ...
    (rec.puzzles)
  • Re: Rabin vs. RSA/ElGamal
    ... Do you mean that people use the "square and multiply" approach/idea ... When considering the "next" digit of the exponent, ... the power of 16 and then multiply times the plaintext to the power of ... use the binary form of square and multiply to compute the plaintext ...
    (sci.crypt)
  • Re: Enigma 1494 - Powerful logic
    ... Hence, if you're trying to raise a to some arbitrary power b mod c, ... since no-one followed up with the calculation, ... but here all we need to do is square 3, 8 times, each mod 1000. ... so the second digit is a power of 2 mod 10 and we can write down 21 ...
    (rec.puzzles)
  • Re: Square Root Of java.math.BigInteger
    ... to irrationals (and with NaN for imaginaries), ... Double.POSITIVE_INFINITY and the square root calculation ... so for a hundred digit number that is ... nonsquare quickly and then just run your algorithm for the rest, ...
    (comp.lang.java.programmer)
  • Re: Square Root Of java.math.BigInteger
    ... to irrationals (and with NaN for imaginaries), ... Double.POSITIVE_INFINITY and the square root calculation ... so for a hundred digit number that is ... nonsquare quickly and then just run your algorithm for the rest, ...
    (comp.lang.java.programmer)