@githg22_gitlab: Taking a hint from the problem statement itself, I'd suggest that the last sentence is especially relevant here.
"This operation can be implemented using just the X gate and its controlled variants."
!
register!
using()
using
block. As you note, you can't use measurement to do that in an adjointable operation; given that resetting is a special case of measurement, the Reset
operation will also fail to preserve adjointability. The trick is that you need to coherently reset the qubit to |0⟩ without measurement. You can do that because you know exactly what state it's in at the end of the using
, and can unprepare it using only unitary operations. The within
/apply
feature of Q# or the ApplyWithCA
operation will be very handy here.