users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

strange behaviour of fd_solver


From: Johannes Middeke
Subject: strange behaviour of fd_solver
Date: Mon, 22 Jul 2002 14:39:01 +0200 (MEST)

hi,


i tried to solve a puzzle consisting of 6 numerical equations with help of
the finite domain solver, but it showed a (for me) unexpected behaviour.

first the code:

solve(R) :-
   R = [A,B,C,D,E,F,G,H,I,J],
   fd_domain(R,0,9),
   fd_all_different(R),

   (A*1000+B*100+C*10+C) - (A*1000+C*100+D*10+E) #=              (F*10+F),
   (A*1000+F*100+G*10+G) /              (B*10+A) #=        (B*100+H*10+H),
   (I*1000+I*100+G*10+G) + (A*1000+C*100+E*10+H) #= (D*1000+J*100+D*10+E),
   (A*1000+B*100+C*10+C) + (A*1000+F*100+G*10+G) #= (I*1000+I*100+G*10+G),
   (A*1000+C*100+D*10+E) +              (B*10+A) #= (A*1000+C*100+E*10+H),

                (F*10+F) *        (B*100+H*10+H) #= (D*1000+J*100+D*10+E),
   %   F*B*1000 + (B*F + F*H)*100 + F*H*20 + F*H #= D*1000+J*100+D*10+E,

   fd_labeling(R).

(just for readability: the puzzle was:
        ABCC - ACDE =   FF,
        AFGG /   BA =  BHH,
        IIGG + ACEH = DJDE,
        ABCC + AFGG = IIGG,
        ACDE +   BA = ACEH,
          FF *  BHH = DJDG )


when use the original equations prolog finds no solution. but when i alter
the last equation to the one commented out just below (which is
mathematically equivalent) prolog finds the right answer.

but what really puzzled me: when i delete all equations and use only the
last (in the original form), prolog finds no answer eather...


can someone explain this to me ???




reply via email to

[Prev in Thread] Current Thread [Next in Thread]