# Removing specific sublists

I have a program that generates a list of specific 3-tuples of integers. A typical output is as follows:

list = {{0, 0, 2}, {0, 1, 1}, {0, 2, 0}, {1, 0, 1}, {1, 1, 0}, {2, 0, 0}}


I want to remove all 3-tuples {x_,y_,z_} where $$x$$ or $$y$$ (or both) are odd. The output in the example should be

cleanlist = {{0,0,2},{0,2,0},{2,0,0}}


Note that 1 isn't the only odd integer that can appear.

I tried using something like cleanlist = DeleteCases[DeleteCases[list, {_OddQ,y_,z_}],{x_,_OddQ,z_}], but unfortunately OddQ doesn't behave like Integer.

Any help is appreciated

• Try DeleteCases[list, {_?OddQ, _, _} | {_, _?OddQ, _}] and report back. – J. M.'s torpor May 27 '20 at 18:59
• It works, thanks! – johnny May 27 '20 at 19:02

## 2 Answers

Cases[{__?EvenQ, _}] @ list

{{0, 0, 2}, {0, 2, 0}, {2, 0, 0}}

DeleteCases[Except @ {__?EvenQ, _}] @ list

{{0, 0, 2}, {0, 2, 0}, {2, 0, 0}}

Select[Apply[And] @* EvenQ @* Most] @ list

{{0, 0, 2}, {0, 2, 0}, {2, 0, 0}}

GroupBy[Total[Mod[ #, 2]] &][list][0]

 {{0, 0, 2}, {0, 2, 0}, {2, 0, 0}}

Pick[list, Mod[list[[All, 1 ;; 2]], 2].{1, 1}, 0]