Sakura Once-Only Gate
The messenger sometimes delivers the same petal ticket twice. Build a gate program that stamps each new ticket onceโand never repeats the same job.
๐ง Before we start
At the castle, you remembered votes before making one shared decision. Today, the gate remembers a ticket's unique token. This makes an action idempotent: repeating the same request still changes the festival only once.
Arrange the gate program
Tap the four visual instruction blocks in the safe order. The gate must check a token before stamping its petal.
Handle three deliveries
Tap every messenger card. Two cards share token P7, so the second P7 must be skipped. P9 is a new job.
๐จ DELIVERY LINE
๐ง REMEMBERED TOKENS
Survive a lost reply
Ticket K4 was stamped and remembered, but the messenger never received the โdoneโ reply. The same ticket returns. Choose the safe retry.
Debug the double-stamp gate
The buggy gate stamps first and checks the token afterward. A duplicate has already changed the festival twice. Move the check before the action.
๐ What you learned
- An idempotent action stays safe when the same request repeats.
- A unique token tells the program whether two deliveries are really one request.
- The program checks remembered tokens before changing anything.
- New tokens act once and are then remembered.
- Repeated tokens skip the action but can still receive a reply.
- Safe retries prevent lost replies from creating duplicate work.