How to extract mutually disjoint elements of a list of lists
Extract mutually disjoint elements of a list:
I have a list of lists, for example:
my_list = {{1,2,9},{2,3,7},{5,6,9},{8,10,11}}
my_list = {{1,2,9},{2,3,7},{5,6,9},{8,10,11}}
Result is :(Try this ) i got form web
fn=Module[{ms = Subsets[#, {2, Length@#}]}, Take[Reverse[Pick[ms, And @@ DisjointQ @@@ Subsets[#, {2}] & /@ ms]],
UpTo[1]]] &; mylist = {{1, 2, 9}, {2, 3, 7}, {5, 6, 9}, {8, 10, 11}} fn@mylist
my_list = {{1,2,9},{2,3,7},{5,6,9},{8,10,11}}
Comments
Post a Comment