Thinking of how to solve this problem using bitwise operations...