Sock conveyor
Rover is sorting socks on a short conveyor. Send the parcel east to the star with one useful counted loop.
Loop rule: A qualifying program consists of one for loop with a count of at least 2 and an action-only body that includes a move. Actions outside the loop are allowed for experiments, but those programs do not qualify for this puzzle.
Allowed: for i in range(0): through range(8), move(), turn_left(), turn_right(), comments and blank lines.
Use a literal count from 0 to 8 and a nonempty, action-only indented body. The puzzle requires one loop with count at least 2. For a nonempty range, Python i starts at zero. A zero count visits no values; reading i in code is outside this lesson.
Allowed Python syntax
One top-level for i in range(number):, followed by one or more indented robot actions. Counts are whole numbers from 0 to 8. Comments, blank lines and action calls outside the loop are allowed for experiments, but outside actions do not qualify for this puzzle. No nested loops, conditions, assignments, reading i, pass, else, or other code.
FLOWCHART · INSPECTED PATH
Run an allowed program to check its syntax and reveal the flowchart. Predict first; then inspect every visit.
PLAN VIEW
Flowchart
How to read this chart
Follow the arrows from Start. Rectangles show actions. A diamond asks a question: follow the labelled TRUE or FALSE path. Only the matching path runs; both paths merge before the next step. Stacked branches are alternatives, not consecutive steps.
A Repeat uses a counter: set i = 0, check i < count, run the whole body, add one, and return to the check. Repeat 5 means five body visits; repeat 0 skips the body. The Python spelling for i in range(5): visits counter values 0, 1, 2, 3, 4: five visits. The trace numbers those visits 1–5. The Python loops workshop supports this bounded for/range form; other workshops keep their own allowed syntax.
Counter setup, increment and exit arrows explain the loop; they are conceptual, not extra recorded trace events. Highlighting follows actual actions, decisions and beginning-of-iteration markers. End is highlighted only after an inspected run finishes normally. For Python, the diagram’s counter setup and increment explain repetition; they are not executed assignments. A zero-count range visits no values and does not assign a new value to Python i.
Design on screen or sketch on paper
Edit the short program in the Python editor. Run checks its syntax before drawing the chart; your prediction stays frozen for that run. Worked examples show separate authored programs.
- Draw a rounded Start. Connect each step with an arrow.
- Put each action in a rectangle, in the order it happens.
- For IF, draw a diamond with a yes/no question. Label both TRUE and FALSE arrows, write each branch, then merge them.
- For a loop, mark the repeat count and draw its whole body. Show a counter starting at 0, a counter-less-than-count question, and a YES arrow into the body.
- After the body, add 1 to the counter and draw an arrow back to its question. The NO arrow leaves the loop. A count of 0 goes straight to NO.
- Finish with a rounded End. Trace with a finger or pencil; note position, heading and any changing values after each action.
Keep your paper sketch beside you; no photo or upload is needed. Robot doodles are optional. Magnificent robot hats are also optional.
Run an allowed program to see its actions and decisions here.
MAP · FULL ROUTE
Predict Rover’s route
Start: column 1, row 5, facing E. Rover now: column 1, row 5, facing E. Goal: column 4, row 5. No walls.
Help for this loop puzzleHints build in steps. Worked help requires a deliberate choice.
Highest help used on this case in this session: none