Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Problem with sorting an list...

Status
Not open for further replies.

Man1234

Programmer
May 4, 2002
1
ZA
How can i solve this problem by prolog????

A,B,C,D,E,F and G stand for 7 consecutive integers

D is 3 less than A
B is the middle term
F is as much less than B as C is greater than D
G is greater than F

Question: What is the order of the variables?

How can I exactly declare the rules and facts???
Please help... It's urgent.....
^___^
 
Hello.
This program enumerates all patterns.
Please add restriction to this program.

ins(X, L, [X|L]).
ins(X, [L1|LT], [L1|RT]) :- ins(X, LT, RT).

perm([], []).
perm([L1|LT], R) :- perm(LT, W), ins(L1, W, R).

main(A, B, C, D, E, F, G) :-
perm([1, 2, 3, 4, 5, 6, 7], [A, B, C, D, E, F, G]),
D < A,
...,
G > F.

I can't understand &quot;B is the middle term&quot; and
&quot;F is as much less than B as C is greater than D&quot;.
Please write algebraically.
&quot;B = 4&quot; and &quot;C - D = B - F&quot; ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top