RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/MiniZinc/dinesmans-multiple-dwelling-problem.minizinc
2023-07-01 13:44:08 -04:00

12 lines
542 B
Text

%Dinesman's multiple-dwelling problem. Nigel Galloway, September 25th., 2020
include "alldifferent.mzn";
enum names={Baker,Cooper,Miller,Smith,Fletcher};
array[names] of var 1..5: res; constraint alldifferent([res[n] | n in names]);
constraint res[Baker] !=5;
constraint res[Cooper] !=1;
constraint res[Fletcher] !=1;
constraint res[Fletcher] !=5;
constraint abs(res[Smith] -res[Fletcher]) > 1;
constraint abs(res[Cooper]-res[Fletcher]) > 1;
constraint res[Cooper] < res[Miller];
output["\(n) resides on floor \(res[n])\n" | n in names]