Your question is Detect and Clear Register Bitflags. 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.
An AMD Ryzen Embedded peripheral exposes its register states as an array of unsigned 32-bit integers. Given a bitmask of fault flags, scan every register, identify registers containing at least one selected flag, and clear only those selected bits.
Modify the input array in place and return a dictionary containing the updated registers array and the zero-based affected_indices of registers whose selected bits were set. Bits outside the mask must remain unchanged.
Implement clear_register_flags(registers, mask).
registers is a list of nonnegative integers, each representing one 32-bit register value.mask is a nonnegative 32-bit integer. A 1 bit identifies a flag to detect and clear.{"registers": registers, "affected_indices": indices} after modifying registers in place.affected_indices must be ordered from smallest to largest index.def clear_register_flags(registers, mask):