← Bitwise Operators

Set and Clear

medium

Apply both halves of the set/check/clear idiom in sequence: turn set_pos on, then turn clear_pos off, and print the resulting value of n.

Doing this as two separate statements, in order, is deliberate: it’s what makes the third test case well-defined when set_pos and clear_pos are the same position – the set happens, and then the clear immediately undoes it, so the net effect on that bit is nothing. Trying to combine both into one clever expression is more likely to get that tie-breaking case wrong than doing it in two obvious steps.

Your solution

"Run" uses the sample stdin ("0 1 3"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution