Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Finding subset of lists with common entries

Suppose I have a list of lists. For example,

[ [1, 2, 3, 4], [1, 3, 1, 3], [4, 1, 4, 1], [1, 3, 2, 1], [4, 1, 2, 4] ]

I want SageMath to give me a sub-list of this list that consist of lists where any two have at least one common entry. For example,

[ [1, 2, 3, 4], [1, 3, 1, 3], [1, 3, 2, 1] ]

or

[ [4, 1, 4, 1], [1, 3, 2, 1], [4, 1, 2, 4] ] .

What would be even more amazing is if SageMath could find the largest possible such sub-list. How could I get SageMath to do this? Thank you in advance!