YOU SHOULD NOT USE ”;” , ”!” AND ”–>” IN YOUR PROLOG RULES.
ALSO, YOU CANNOT USE SYSTEM PREDICATES OR LIBRARIES NOT MENTIONED IN CLASS.
EXAMPLE FROM LAST YEAR
ANSWER
floor(1). floor(2). floor(3). floor(4). floor(5). floor(6). floor(7). floor(8). floor(9). floor(10). floor(11). floor(12). floor(13). floor(14). floor(15). floor(16). floor(17). floor(18). floor(19). floor(20).
all_diff([]).
all_diff([H|T]) :- not member(H,T), all_diff(T).
/* smart interleaving of generate and test technique took Time: 0.297 */
solve1([P,R,S,T,B,CS,D,A]) :-
floor(P), floor(S), P>S, floor(T), P
floor(B), B-2-A =:= (D – A)//2,
P = B,
D is S * 2,
R * 2 =:= A – 2,
D >= T,
all_diff([P,R,S,T]), all_diff([B, CS, D,A]).