Your question is Flip One Bit. 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.
Abbott device protocols such as FreeStyle Libre may encode sensor status and measurement flags in individual bits of a byte. Given an unsigned 8-bit value and a bit position, flip exactly that bit and return the resulting byte.
Bit positions are numbered from 0 through 7, where position 0 is the least significant bit. Flipping means changing 0 to 1 or 1 to 0, while leaving every other bit unchanged.
Implement flip_bit(byte_value, bit_position).
byte_value, an integer from 0 through 255, and bit_position, an integer from 0 through 7.0 through 255 representing byte_value after the selected bit is toggled.def flip_bit(byte_value, bit_position):