Write an unambiguous instruction — quick review
Ask two friends to pick out a big card from the same row, and they may pick different cards.
Each step of an algorithm has exactly one reading. The steps are carried out in the order written unless a step says where to go next. Two readers who follow the same steps on the same input do the same things and reach the same output.
Number the steps and write each one as a short instruction.
Give a name to each thing the steps use, such as the noted number, and use the same name every time.
Replace each vague word with a test a reader can carry out. Step 3 of the largest-card procedure does not say a big card. It names one card, the card taken in step 2, and one test: its number is larger than the noted number.
For each question a step asks, say what to do for yes. Say what to do for no as well, unless the reader then goes on to the next step in order, as after step 3 of the largest-card procedure. Step 2 covers both answers: go to step 5 when no card is left, and take the next card otherwise.
Say where to go after a step whenever that is not the next step in order.
Read the steps as a reader who knows nothing else would, and mark any place where two actions are possible.
The usual gap is a case nobody wrote down. Suppose step 2 said only this: take the next card. On the row 4 9 2 a reader reaches the end of the row with no instruction for what comes next. One reader stops, and another starts again from the first card. Write the instruction for the case where no card is left.
A second question sits in the word larger. If step 3 acted for a card that is larger than or equal to the noted number, the row 5 5 3 would still give 5, and the reader would rewrite the slip one more time on the way. Each wording has one reading. The step must say which of the two it means.