Your question is Flip a Bit at Position. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Box services may represent compact file or folder attributes as a 32-bit unsigned integer. Given a packed flags value and a zero-based bit position, flip the bit at that position and return the updated integer.
Flipping means changing 0 to 1 or 1 to 0. All other bits must remain unchanged. Use bitwise operations rather than converting the number to a string or scanning its binary representation.
Implement flip_bit(flags, position):
flags is a non-negative 32-bit integer.position is an integer from 0 through 31, where position 0 is the least significant bit.The input is always valid, and the function must not mutate external state.
def flip_bit(flags, position):