tags:

views:

67

answers:

1

Hello all. I need to do the following: given a list of lists I need to find all possible combinations of the lists such that if some of these lists belong in such a combination, then they have no elements in common and the list created by appending the lists in the combination has a given length. Any ideas?

Thanx

A: 

Example:

Say P= [[1,2,3],[4,5,6],[2,5],[7,9],[7,10],[8],[10]]. and N a given number, say N=10. I need to search through P in order to find appropriate lists, with no elements in common, and add them in a list L such that the length of the union of L is 10. So in the above example : L=[[1,2,3],[4,5,6],[7,9],[8],[10]]. It might be very easy but im new in Prolog

Thanx

bob