Re: A new solution to the N-queens problem ?

From: Pento (robby.goetschalckx_at_student.kuleuven.ac.be.NOSPAM)
Date: 04/26/04

  • Next message: Paulo Moura: "Logtalk 2.17.0 is now available for downloading"
    Date: Mon, 26 Apr 2004 10:16:13 +0000 (UTC)
    
    

    google@philosophons.com (Cl?ment) wrote in
    news:ae737f26.0404250859.e945993@posting.google.com:

    > % Forbid the diagonals.
    > % In general, 2 queens attacks each others if abs(Xi-Xj)= abs(i-j).
    >
    > ... That's were my programm stops :(
    > I thought to generate all the couples of Xi first, and then compare
    > the list with the predicate nth1\3 (integrated in Prolog).
    > I've tried the following thing, but this is wrong (not all the
    > possibilities are eliminated):
    >
    > % diag(Qs) :-
    >
    > % member(X,Qs),
    > % member(Y,Qs),
    >
    > % nth1(X,Qs,Nth),
    > % Y is X+1, nth1(Y,Qs,Nth_plus),
    >
    > % abs(X - Y) = abs(Nth - Nth_plus).

    You only check for "Y is X+1", not for, e.g. "Y is X+2".

    -- 
    Pento
    De wereld was soep, en het denken meestal een vork,
    tot smakelijk eten leidde dat zelden. - H. Mulisch
    

  • Next message: Paulo Moura: "Logtalk 2.17.0 is now available for downloading"