Naive solution to find next smallest or largest integer with the same number of bits set as the given integer