I have a list of tuples like this:
{{1,a,b},{1,1,b},{1,a,a},{b,a,1},{b,a,b}}
I would like to find a way to delete all those tuples in the list that contain a duplicate unless that duplicate is a 1
. Therefore, the desired result given the example input above would be:
{{1,a,b},{1,1,b},{b,a,1}}
I will also need to delete duplicate elements within the list (irrespective of sorting) but that is easily done (i.e. only keep one of {1,a,b}
and {b,a,1}
).
I would like it to work for generic length tuples too, for example:
{{1,1,1,1},{1,a,a,b},{a,b,b,c},{1,a,b,c},{1,1,a,b}}
would become
{{1,1,1,1},{1,a,b,c},{1,1,a,b}}