So... What happens if the interviewee doesn't go the way interviewer expects? Like, what if I answer with this:
bin(x ^ (x >> 1))
Most often interviewers get quite irritated if interviewer comes up with a much simplier and a faster solution than what was intended.