While preparing an answer to Secret Santa - Generating 'valid' permutations I came across the need to check if a list contains zero. I am wondering what the fastest way to do this in Mathematica 7 is, with emphasis on a short list of non-negative integers.
Using Min[list] === 0
is the fastest I have found, faster than MemberQ
or FreeQ
, but I am hoping there is a faster way, on par with the BitXor
operation below:
r = Range@9;
p = Permutations@r;
BitXor[r, #] & /@ p; // Timing
0 === Min[BitXor[r, #]] & /@ p; // Timing
{0.062, Null}
{0.452, Null}