You are viewing a single comment's thread. Return to all comments →
Python 3
def changeBits(a, b, queries): a, b = int(a, 2), int(b, 2) for q in queries: q = q.rstrip().split() i = int(q[1]) if q[0] == 'set_a': if q[2] == '1': a |= 1<<i else: a &= ~(1<<i) elif q[0] == 'set_b': if q[2] == '1': b |= 1<<i else: b &= ~(1<<i) else: c = a + b if not c & (1<<i): print('0', end="") else: print('1', end="")
Seems like cookies are disabled on this browser, please enable them to open this website
Changing Bits
You are viewing a single comment's thread. Return to all comments →
Python 3