Say I have two lists [A, B, C] and [D, E, F] on my hand now.
The values in list1 and list2 are in the same range, but I don't exactly know how they match with each other.
There is one possibility that A = D = 1, B = E = 2, C = F = 3.
Based on the condition above, how can I print the result in the following format???
(ONE, A, D)
(TWO, B, E)
(THREE, C, F)
The original problem is, you have to figure out the value of each variable in list1 and list2 under the given constraints. The constraints are as following:
A < B, B < C, D < E, E < F,
the range of [A, B, C] is from 1 to 3,
the range of [D, E, F] is from 1 to 3,
[A, B, C] are all different numbers,
[D, E, F] are all different numbers.
So far I write something like:
calculate([A, B, C, D, E, F]) :-
between(1, 3, A),
between(1, 3, B),
between(1, 3, C),
between(1, 3, D),
between(1, 3, E),
between(1, 3, F),
A < B, B < C, D < E, E < F.
After I consult this code file and call calculate([A, B, C, D, E, F]), I get the final result A = D = 1, B = E = 2, C = F = 3, but how can I print in an elegant format???
write('A = '), write(A)- Acepcs