Skip to content

Instantly share code, notes, and snippets.

@benallard
Created May 25, 2015 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benallard/07629ad80c77eb2ccacd to your computer and use it in GitHub Desktop.
Save benallard/07629ad80c77eb2ccacd to your computer and use it in GitHub Desktop.
include "alldifferent.mzn";
var 1..9: a;
var 1..9: b;
var 1..9: c;
var 1..9: d;
var 1..9: e;
var 1..9: f;
var 1..9: g;
var 1..9: h;
var 1..9: i;
constraint a + 13 * b div c + d + 12 * e - f - 11 + g * h div i - 10 = 66;
constraint 13 * b mod c = 0;
constraint g * h mod i = 0;
constraint alldifferent([a,b,c,d,e,f,g,h,i]);
solve satisfy;
output [show(a), show(b), show(c), show(d), show(e), show(f), show(g), show(h), show(i), "\n"];
@benallard
Copy link
Author

Replacing the "div" with "/", and removing both "mod" constraint, we can get the 'rational' solutions:

$ mzn-gecode -a pb.mzn 
892315764
----------
392815764
----------
892315674
----------
392815674
----------
941527836
----------
541927836
----------
931625874
----------
631925874
----------
693521874
----------
593621874
----------
931625784
----------
631925784
----------
731526984
----------
531726984
----------
941527386
----------
541927386
----------
693521784
----------
593621784
----------
731526894
----------
531726894
----------
872539614
----------
872539164
----------
572839614
----------
572839164
----------
986241753
----------
286941753
----------
986241573
----------
286941573
----------
153942876
----------
953142876
----------
153942786
----------
953142786
----------
852147936
----------
152847936
----------
321547986
----------
521347986
----------
152847396
----------
852147396
----------
321547896
----------
521347896
----------
152348976
----------
352148976
----------
152348796
----------
352148796
----------
752849316
----------
852749316
----------
752849136
----------
852749136
----------
183745629
----------
783145629
----------
183745269
----------
783145269
----------
196752438
----------
196458732
----------
132956748
----------
196752348
----------
196458372
----------
132956478
----------
132458976
----------
132458796
----------
796152438
----------
796152348
----------
496158732
----------
932156748
----------
932156478
----------
496158372
----------
432158976
----------
432158796
----------
764859312
----------
864759312
----------
732859614
----------
832759614
----------
364958712
----------
964358712
----------
396251748
----------
396251478
----------
869251743
----------
869251473
----------
296351748
----------
296351478
----------
628351974
----------
824351976
----------
964358172
----------
628351794
----------
824351796
----------
328651974
----------
328651794
----------
864759132
----------
832759164
----------
764859132
----------
269851743
----------
732859164
----------
269851473
----------
324851976
----------
324851796
----------
364958172
----------
948567312
----------
928765314
----------
728965314
----------
548967312
----------
914765328
----------
714965328
----------
734165928
----------
134765928
----------
948567132
----------
548967132
----------
928765134
----------
728965134
----------
714965238
----------
914765238
----------
512967438
----------
912567438
----------
512967348
----------
912567348
----------
734165298
----------
134765298
----------
314279658
----------
314279568
----------
214379658
----------
214379568
----------
426178539
----------
126478539
----------
426178359
----------
126478359
----------
236179548
----------
236179458
----------
136279548
----------
136279458
----------
439178526
----------
139478526
----------
439178256
----------
139478256
----------
248179536
----------
248179356
----------
148279536
----------
148279356
----------
==========

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment