A growing list of bit twiddles as I come across them.
If we XOR with 1 we flip a bit.
Therefore to flip all the bits in a 32-bit integer:
return n ^ int('11111111111111111111111111111111', 2)
where the number of 1s in the string is 32.