@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."
usingblock. 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
Resetoperation 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
applyfeature of Q# or the
ApplyWithCAoperation will be very handy here.
By the way, @crazy4pi314 will be streaming with @bettinaheim about the Q# compiler today in a little under three hours if anyone is interested to join at https://twitch.tv/crazy4pi314. More details at https://twitter.com/crazy4pi314/status/1271837229221101569.