% For Text, p. 432

% member(X,[X|_]).
% member(X,[_|Y]) :- member(X, Y).

print_floors([A|B]) :- write(A),nl,print_floors(B).
print_floors([]).

adjacent(X,Y) :- X =:= Y+1.
adjacent(X,Y) :- X =:= Y-1.

notadj(X,Y) :- T is Y+1, U is Y-1, X\==T, X\==U.

floors([floor(_,5),floor(_,4),floor(_,3),floor(_,2),floor(_,1)]).

building(Floors) :- floors(Floors),
	member(floor(baker, B), Floors), B\==5,
	member(floor(cooper, C), Floors), C\==1,
	member(floor(fletcher, F), Floors), F\==1, F\==5,
	member(floor(miller, M), Floors), M>C,
 	member(floor(smith, S), Floors), 
        %not( adjacent(S, F) ),
        notadj(S,F),
	%not( adjacent(F, C) ),
        notadj(F,C),
	print_floors(Floors).

