try to write shortest possible variant of logic which converts binary input by this table:
00 -> 00 01 -> 10 10 -> 01 11 -> 11 You can use only bitwise and bitshift operations. I calculate only operations and don't care brackets, spaces, constants and etc. But you can't use any control (if, while, ternary) and arithmetic operations.
If you are using bitwise and bitshift operations, your operations number will be multipled by two:
op_num = (your_op_num << types_of_operation_num) >> 1 edit: sorry, this is not real code-golf, because I calculate operations in logic, not characters.
rolwould do this in one instruction (if it could operate on only 2 bits). \$\endgroup\$1x & 1y- x and y can't affect the result of the first bit.). So every logic based solution has to use both of them. \$\endgroup\$