I think this is doable, basically unfolding a typical cycle and being generally annoying.
How about this: an expression that is 1 if and only if the answer is 1? I suggest:
const int ok1 = !((number & 0xc0000000) - 0x800000000);
!and subtraction should work for someone to break the key ==on our keyboard, of course.
And then an expression that is 1 if and only if anwer is 2:
const int ok2 = !((number & 0xe0000000) - 0xc0000000);
If you continue to form them, the final answer will be their sum:
const int answer = ok1 + ok2 + ... + ok32;
By the way, I can’t remember that I was given these strangely limited tasks when I was in school, I think the times have changed. :)
source
share