ext_214513 ([identity profile] http://users.livejournal.com/_fluffy/) wrote in [personal profile] austin_dern 2012-10-02 04:02 pm (UTC)

Oh, and here's the version which also finds the row values:

paytherent(X,[A,[B1,B2],[C1,C2],D],[A,B3,C3,D]) :- 
	permutation(X,[A,B1,B2,C1,C2,D]), 
	B2>B1, B1+B2 > A, B3 #= B1+B2,
	C2>C1, C1+C2 > B1+B2, C3 #= C1+C2,
        D > C1+C2.


You call it with paytherent(Pricelist,Order,RowTotals), and as always (for Prolog) pass in a _ to say you don't care about that parameter.

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting