TactivergeLite

Lite / Discovering How the World Works / Week 21

Order matters

A lift opens its doors, then moves to floor 7. Every step was correct. Why is everyone screaming?

About 25 min · 3 goals · Reviewed by the founders' mentors · Full interactive version

Why should I care?

In real machines the order of steps is often a matter of safety. A lift must close its doors before it moves; a washing machine must drain before it unlocks. Engineers spend a lot of time asking 'what has to be true before this step is allowed?'

Predict

A robot runs 'Turn right, then Forward 2' from (0, 0) facing north. A second robot runs 'Forward 2, then Turn right'. Do they end up in the same square?

  1. Yes, same steps
  2. No, they end in different squares
  3. Only if the grid is empty
Guess first, then reveal

Different squares. The first turns to face east, then moves to (2, 0). The second moves north to (0, 2), then turns. Same instructions, different order, different result.

Discover

Watch a lift trip, then put the seven stages of a trip in order. For each stage, ask: what must already have happened before this is safe?

What the interactive shows (text version)

The lift activity can be replaced by this description: a lift has a counterweight (balances the cabin), a door-edge sensor (detects anything in the doorway), a floor position sensor (where the cabin is), a load-weighing sensor (how heavy it is) and a motor with a pulley (turns the ropes). A trip goes: call registered, doors close, accelerate, cruise, slow down, level, doors open.

You can also open the interactive on the full site when you have a faster connection.

Understand

A sequence is steps in order

A sequence is the simplest kind of algorithm: do this, then this, then this. Most programs are mostly sequences, with decisions and loops mixed in.

Swapping steps can change everything

Some steps don't care about order: putting on your left sock or right sock first. Others do: socks before shoes. Turning before or after moving sends a robot to a completely different place.

Before-and-after rules

Engineers write down which steps must come before others: 'doors closed before the lift moves', 'drain before unlock'. Any order that breaks one of these rules is unsafe, even if every individual step is fine.

Explain it another way

Intuitive

Baking a cake: mix, then bake, then ice. Ice, then bake, then mix gives you a disaster made of exactly the same ingredients.

Technical

Operations that change the system's state usually do not commute: doing A then B gives a different state from B then A. Engineers record ordering constraints as 'A must happen before B'.

Applied

Lift controllers use interlocks: the motor physically cannot be powered until the door-closed sensor confirms the doors are shut. The order is enforced by the design, not just by the program.

Worked example 1

Put these lift stages in a safe order: accelerate, doors open, call registered, level with the floor, doors close, cruise, slow down.

Call registered → doors close → accelerate → cruise → slow down → level with the floor → doors open. The key rules: doors must close before any movement, and must not open until the cabin is level.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 1. Which pair of steps can safely be done in either order?
Practice 2. A robot at (0, 0) faces north. It runs: Turn right, Forward 1, Forward 1. Where does it end?
Practice 3. What must happen before a washing machine's door is allowed to unlock?

Apply it

Write the steps for a robot that makes a cup of squash (fetch cup, add squash, add water, stir, serve). Which steps can swap places, and which must never swap? Write one 'must happen before' rule.

Reflect

Think of a time you did the right things in the wrong order. What happened?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Some algorithms are better than othersInstructions a robot can't misunderstand →