RosettaCodeData/Task/Dinesmans-multiple-dwelling-problem/Picat/dinesmans-multiple-dwelling-problem-1.picat
2023-07-01 13:44:08 -04:00

33 lines
754 B
Text

import util.
import cp.
dinesman_cp =>
println(dinesman_cp),
N = 5,
X = [Baker, Cooper, Fletcher, Miller, Smith],
X :: 1..N,
all_different(X),
% Baker does not live on the fifth floor.
Baker #!= 5,
% Cooper does not live on the first floor.
Cooper #!= 1,
% Fletcher does not live on either the fifth or the first floor.
Fletcher #!= 5,
Fletcher #!= 1,
% Miller lives on a higher floor than does Cooper.
Miller #> Cooper,
% Smith does not live on a floor adjacent to Fletcher'.
abs(Smith-Fletcher) #> 1,
% Fletcher does not live on a floor adjacent to Cooper's.
abs(Fletcher-Cooper) #> 1,
solve(X),
println([baker=Baker, cooper=Cooper, fletcher=Fletcher, miller=Miller, smith=Smith]).