Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constraint programming boolean solver

Huey, Dewey and Louie are being questioned by their uncle. These are the statements they make:

• Huey: “Dewey and Louie had equal share in it; if one is guilty, so is the other.”

• Dewey: “If Huey is guilty, then so am I.”

• Louie: “Dewey and I are not both guilty.”

Their uncle, knowing that they are scouts realizes that they cannot tell a lie.

My solution.

var bool :D; var bool :L; var bool :H;
    constraint D <->L;
    constraint H -> D;
    constraint D!=L;
    solve satisfy;
    output[show(D), "\n", show(L),"\n", show(H)];

Minizinc can't solve it.

like image 927
user2975699 Avatar asked Sep 12 '26 21:09

user2975699


1 Answers

Here's my (old) version of this problem: http://www.hakank.org/minizinc/huey_dewey_louie.mzn

 var bool: huey;
 var bool: dewey;
 var bool: louie;

 constraint
   %  Huey: Dewey and Louie has equal share in it; if one is quitly, so is the other.
   (dewey <-> louie)

   %  Dewey: If Huey is guilty, then so am I.
   /\
   (huey -> dewey)

   %  Louie: Dewey and I are not both quilty.
   /\
   (not (dewey /\ louie))
;
like image 130
hakank Avatar answered Sep 16 '26 15:09

hakank