Preparing the catalog and filters…Katalog ve filtreler hazırlanıyor…
Starter code
module bounded_retry;
@seed(7);
fn main() {
let q: QReg<1> = qreg[1];
until (flag == 1) max 6 {
H(q[0]);
let flag: Bit = measure(q[0]);
reset q[0];
}
assert probability(|0>) > 0.99;
return flag;
}Expected output
The seed makes the retry sequence reproducible
Output lists each until iteration
The loop stops when flag becomes 1 or the max bound is reached
reset returns the qubit to |0> after each attempt
Debugging checklist
Run the lab and find the Until iteration lines in Output
Open Trace and locate the until check for flag
Change max 6 to max 1 and compare the result
Replace H with X and confirm the loop succeeds immediately
Explain why max is required for safe repeat-until-success code
Extension challenge
Add a second measured Bit and use match after the until block to choose a correction branch.