Being pedantic, as they said no if keyword, then the trojans should be fair play ...
return (x1+1 == x2) ? x1+2 : x1+1;
Of course, maybe this is a hoax. No problem, there is a ternary version:
return x1+1+(x1+1==x2);
And don't worry if you think the conditional is still cheating, there are many ways to implement it using direct bit manipulation.
Note that the add solution is only valid for unsigned integers, since it induces the potential for signature overflows (which is UB). If this is a concern, you can replace the addition with another operation (e.g. x1^(1+(x1^1==x2) ).
source share