Re: position 8 queens on a board without attack
From: Gregor Rot (zara4tustra_at_yahoo.com)
Date: 04/09/04
- Next message: bart demoen: "Re: position 8 queens on a board without attack"
- Previous message: Bart Demoen: "Re: position 8 queens on a board without attack"
- In reply to: Bart Demoen: "Re: position 8 queens on a board without attack"
- Next in thread: bart demoen: "Re: position 8 queens on a board without attack"
- Reply: bart demoen: "Re: position 8 queens on a board without attack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 09 Apr 2004 18:48:07 +0200
Bart Demoen wrote:
> Gregor Rot wrote:
>
>>
>> solution([]).
>>
>> solution([X/Y|Others]):-
>> solution(Others),
>> member(Y,[1,2,3,4,5,6,7,8]),
>> noattack(X/Y,Others).
>>
>> member(X,L):-
>> iteration,
>> conc(L1,[X|L2],L).
>>
>
> versus
>
>
>> solution([X/Y|Others]):-
>> solution(Others),
>> member(Y,[1,2,3,4,5,6,7,8]),
>> iteration,
>> noattack(X/Y,Others).
>>
>> member(X,L):-
>> conc(L1,[X|L2],L).
>>
>
> I have ommitted the code that does not change.
>
> The difference is between putting the counter update at the entry of
> member,
> versus at the exit of member. I.e. your last version is equivalent to:
>
>
> > solution([]).
> >
> > solution([X/Y|Others]):-
> > solution(Others),
> > member(Y,[1,2,3,4,5,6,7,8]),
> > noattack(X/Y,Others).
> >
> > member(X,L):-
> > conc(L1,[X|L2],L),
> > iteration. <<<<<<<<<<<<<<<<<<<<<< here is the difference
>
> Of course you get different results, since 1 entry usually corresponds to
> many exits (for member).
>
> Which one is of interest to you, I don't know: the second counts how often
> the program tests a proposal for an extension to a partial (potential)
> solution.
> You could argue that any time this happens, it is a combination that Prolog
> has tried out, so the 877 seems the number you want.
>
> Cheers
>
> Bart Demoen
Thank you very much for your time and explanation,
Best regards,
Gregor
- Next message: bart demoen: "Re: position 8 queens on a board without attack"
- Previous message: Bart Demoen: "Re: position 8 queens on a board without attack"
- In reply to: Bart Demoen: "Re: position 8 queens on a board without attack"
- Next in thread: bart demoen: "Re: position 8 queens on a board without attack"
- Reply: bart demoen: "Re: position 8 queens on a board without attack"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]