From up above, set (z) start at 11111111111111111111111111 deadbit string = 11111111111111111111111110 start & deadbit = 11111111111111111111111110 this is > 0, so xor. (start ^ deadbit) & start = 00000000000000000000000001 Bang! one and, a conditional, and an xor jumped you past 67 million some odd invalid sets. Another one, from above, set (ABCD) start at 1111 deadbit string = 1110 start & deadbit = 1110 this is > 0, so xor (start ^ deadbit) & start = 0111 (starts at BCD Here's a more complex example. Assume our first set was ABC, and our next was ABD. (A = 0, B = 1, C = 2, D = 3). When we hit ABD, we flag C as our deadbit and our deadbit string would be 0010. Let's try a complete runthrough: 1111 1111 & 0010 > 0 -> (1111 ^ 0010) & 1111 -> new index is 1101 1101 ABD (1101 & 0010 == 0) 1100 AB (1100 & 0010 == 0) 1011 (1011 & 0010 == 0) 1011 & 0010 > 0 -> (1011 ^ 0010) & 1011 -> new index is 1001 1001 A D (1001 & 0010 == 0) 1000 A (1000 & 0010 == 0) 0111 0111 & 0010 > 0 -> (0111 ^ 0010) & 0111 -> new index is 0101 0101 B D (0101 & 0010 == 0) 0100 B (0100 & 0010 == 0) 0011 0011 & 0010 > 0 -> (0011 ^ 0010) & 0010 -> new index is 0001 0001 D (0001 & 0010 == 0) 0000 () (0000 & 0010 == 0)