Your question is Bit Matching With Wildcards. 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.
A General Atomics MQ-9 telemetry packet contains two unsigned bytes, A and B. Their eight-bit representations follow these layouts:
A: 0101X110B: 1Y011001The digits 0 and 1 are arbitrary bit values supplied by the packet. Bit X is the fifth bit from the left in A, and bit Y is the second bit from the left in B. Return True when X and Y have the same value, otherwise return False.
Use bitwise operations rather than converting the bytes to strings. The function must work for every valid pair of bytes, regardless of the other bit values.
Implement compare_telemetry_bits(A, B), where A and B are integers representing unsigned eight-bit values. Return a Boolean. Since bit positions are counted from the least significant bit at index 0, X is bit 3 of A, and Y is bit 6 of B.
def compare_telemetry_bits(A, B):