How to remove sublists whose difference of two elements is either 1 or 11?

test[sublist_] := ContainsNone[Abs[Subtract @@@ Subsets[sublist,{2}]], {1,11}]

Select[Subsets[Range[12], {3}], test]

For your problem in the comments, the number of triangles in a regular polygon which do not share any sides with that polygon is $n (n - 4) (n - 5)/6$ provided $n\ge6$. It would be much more efficient to use this result directly than to list them and count them.


You may use SubsetCount. This is an experimental function in version 12.1.1 so behaviour may change.

Select[
  SubsetCount[#, {j_, k_} /; Or @@ Thread[j - k == {1, 11}]] == 0 &
  ]@Subsets[Range[12], {3}]

Hope this helps.


Not an answer,only a review.

the question is equivalence to $$1\leq a < b <c \leq 12,b-a\geq 2,c-b\geq 2$$ and when $a=1$, $c\not=12$ or when $c=12$,$a\not=1$

If we mapping $\{a,b,c\}$ to $\{a,b-1,c-2\}=\{i,j,k\}$

the question is equivalence to $$2\leq i < j <k \leq 9$$ or $$1=i,2\leq j<k\leq 9$$ or $$2\leq i<j\leq 9,k=10$$

so the number of subsets is ${8\choose 3}+2{8 \choose 2}=112$

Similarly the general result is ${n-4\choose 3}+2{n-4\choose 2}$ where the $n$ is the length of subsets $\{1,2,\cdots,n\}$ ( here $n=12$)