Zebra puzzle: Difference between revisions
Content deleted Content added
→Direct rule by rule translation: add white space to code for legibility |
→Direct rule by rule translation: args order tweak |
||
Line 5,081: | Line 5,081: | ||
attrs( H, [N-V | R]) :- memberchk( N-X, H), X = V, (R = [] -> true ; attrs( H, R)). |
attrs( H, [N-V | R]) :- memberchk( N-X, H), X = V, (R = [] -> true ; attrs( H, R)). |
||
in( |
in( HS, Attrs) :- member( H, HS), attrs( H, Attrs). |
||
in( |
in( G, HS, AttrsL) :- call( G, Args, HS), maplist( attrs, Args, AttrsL). |
||
left_of( [A,B], HS) :- append( _, [A,B | _], HS). |
left_of( [A,B], HS) :- append( _, [A,B | _], HS). |
||
Line 5,098: | Line 5,098: | ||
, [ nation-german, smoke-'Prince' ] % 14 |
, [ nation-german, smoke-'Prince' ] % 14 |
||
] ), |
] ), |
||
in( |
in( left_of, Houses, [[color -green ], [color -white ]]), % 5 |
||
maplist( attrs, [C,A], [[drink -milk ], % 9 |
maplist( attrs, [C,A], [[drink -milk ], % 9 |
||
[nation-norwegian]]), % 10 |
[nation-norwegian]]), % 10 |
||
maplist( in( |
maplist( in( next_to, Houses), |
||
[ [[smoke -'Blend' ], [owns -cats ]] % 11 |
[ [[smoke -'Blend' ], [owns -cats ]] % 11 |
||
, [[owns -horse ], [smoke-'Dunhill' ]] % 12 |
, [[owns -horse ], [smoke-'Dunhill' ]] % 12 |
||
Line 5,121: | Line 5,121: | ||
german |
german |
||
No More Solutions |
No More Solutions |
||
% |
% 235,165 inferences, 0.031 CPU in 0.040 seconds (78% CPU, 7537291 Lips)</lang> |
||
===Alternative version=== |
===Alternative version=== |