:- use_module(library(clpfd)).

% propagate and search 

% Find a rectangle whose perimeter is 20 and area greater than or
% equal to 24, and width is less than height.
% Find W,H so that (W+H = 10) ^ (W*H >=24) ^ (W < H)

rectangle([W,H]) :-
	W in 0..9, H in 0..9,
	W+H #= 10,
	W*H #>= 24,
	W #< H.

rectangleSolve(rect(W,H)) :-
	rectangle([W,H]),
	label([W,H]).

palindrome(A,B,C,X,Y) :-
	A in 1000..9999, B in 0..99, C in 0..99,
	A #= B * C,
	X in 1..9, Y in 0..9,
	A #= X*1000+Y*100+Y*10+X.
	
palindromeSolve(A) :-
	palindrome(A,_,_,X,Y),
	labeling([ff], [X,Y]).

palindromeSolveAll(L,N) :-
	findall(S, palindromeSolve(S), L), length(L,N).  % 36 solutions

