In embedded systems such as firmware interacting with Meta hardware, registers are often updated by changing one bit at a time. Write a function that applies a sequence of bit operations to an integer register.
Given an initial integer register, and a list of operations ops, return the final register value after processing each operation in order. Each operation is a pair [action, bit_index], where action is one of:
"set": set the bit at bit_index to 1"clear": clear the bit at bit_index to 0"toggle": flip the bit at bit_indexregister: integerops: list of [action, bit_index]Example 1
Input: register = 0, ops = [["set", 1], ["set", 3], ["toggle", 1]]
Output: 8
Explanation: 0 -> 2 -> 10 -> 8
Example 2
Input: register = 13, ops = [["clear", 2], ["toggle", 0]]
Output: 8
Explanation: 13 is 1101 in binary. Clearing bit 2 gives 1001 (9), then toggling bit 0 gives 1000 (8).
0 <= register <= 10^91 <= len(ops) <= 10^50 <= bit_index <= 30action is one of "set", "clear", or "toggle"