Skip to main content
8 of 9
added 94 characters in body
kglr
  • 400.5k
  • 18
  • 488
  • 929
ClearAll[f1, f2, f3]
f1 = Cases[{___, {Except[a_]..., a_, Except[a_]...}, ___}]@*Cases[{___, {(a_)..}, ___}];
f1 = Select[MemberQ[Tally /@ #, {_, 1}, All] &]@*Cases[{___, {(a_)..}, ___}] ;
f2 = Pick[#, MemberQ[#, {_, 1}, All]& /@ Map[Tally, #, {2}]]& @*Cases[{___, {(a_)..}, ___}];

Examples:

lst1 = {{{4}}, {{7, 7}, {7, 7}}, {{5, 5}, {6, 6}}, {{2, 1}, {1, 1}}};
f1 @ lst1

{{{4}}, {{2, 1}, {1, 1}}}

f1 @ lst1 == f2 @ lst1 == f3 @lst1

True

lst2 = {{{3, 3}, {3, 2}}, {{1, 1, 1, 1}, {1, 2, 3, 0}, {1, 0, 0, 
     0}, {1, 0, 3, 2}}, {{1, 1, 1, 1, 1}, {1, 4, 3, 0, 4}, {1, 3, 3, 
     3, 0}, {1, 0, 3, 4, 4}, {1, 4, 0, 4, 4}}} ;
f1 @ lst2 == f2 @lst2 == f3 @ lst2 == lst2

True

kglr
  • 400.5k
  • 18
  • 488
  • 929