πŸ›— LIFT LAB

You are the elevator's programmer. Build its brain, block by block.
⏱ moving 1 floor costs 1 tick  Β·  🧠 thinking is free  Β·  a person's wait = press β†’ doors open

1 Β· Pick a day

Every button press joins REQUESTS β€” the list of floors waiting, oldest first. Your program decides everything else.

2 Β· Program the lift

The flowchart runs in a loop all day. The β–Ά marker shows the block being executed right now β€” the clock only ticks when the lift moves or waits.
Load an example program:
🧰 Blocks β€” drag onto the canvas
πŸ– drag blocks to move πŸ”Œ drag from a dot onto a block to wire it βœ‚οΈ click a wire β€” or drag it off its dot β€” to unplug ⌨ click a block, then Delete / arrow keys
The Classic Puzzle
⏱ tick0
πŸ›—
🧍 waiting · red number = ticks waited

🧠 The lift's memory

MY FLOOR3
REQUESTS
TARGET0 STEP0
BEST0 DIR0

Scoreboard

0
⏱ ticks
0/0
βœ… picked up
–
Ø avg wait
0
βˆ‘ total wait
0
😀 longest
0
πŸ›— floors moved

Lift diary

3 Β· The grand race

Same day, same presses β€” your program against the three classics. A rule can win one frozen example and still lose a living one.

4 Β· Think deeper

For classrooms, parents, and curious brains.
🧩 Why does β€œClosest First” score 21 on the Classic Puzzle while β€œFirst Come” scores 67?

Load each example and read it like code. First-Come takes item 1 of REQUESTS β€” whoever pressed first β€” and drives there no matter what it passes on the way: 3β†’10β†’2β†’8β†’5, crossing the whole building three times. Closest-First walks the list with STEP and BEST to find the nearest floor before every single move: 3β†’2β†’5β†’8β†’10, almost one clean sweep. Use ⏭ One block and watch BEST change in the lift's memory.

πŸšͺ First-Come drives right past people. Can you fix it?

Watch First-Come on the Classic Puzzle: on its way from 3 to 10 it sails past floors 5 and 8 where people are waiting! Add the β€œis someone waiting on MY FLOOR?” diamond into its loop, wire YES to an OPEN DOORS block, and race again. One extra question, dramatically better numbers β€” that's what algorithm design feels like.

😈 Design a day where β€œClosest First” is cruel. Who pays for its efficiency?

Run The Forgotten Floor with the Closest-First program. Someone presses on floor 9 at the very start, but the lower floors keep pressing and there is always someone closer. The average still looks fine β€” check 😀 longest wait instead. This failure mode has a real name in computer science: starvation.

🧠 Build a brain that is fast AND fair (yes, it's possible)

The Sweeper remembers a direction in DIR and finishes it before turning around β€” that's LOOK/SCAN, what real elevators do. Now add the β€œhas the FIRST person waited more than N ticks?” diamond at the top of your loop, and wire YES into a First-Come-style rescue (set TARGET to item 1, drive there). You've invented aging β€” the trick real operating systems use to stop starvation. Tune N: what happens at 5? At 30?

🌍 Where else does this exact math show up?

Your hard disk schedules read/write requests with SCAN β€” literally the elevator algorithm. Ride-sharing apps decide which car takes which rider. Hospitals triage patients; support queues answer tickets. Any time requests arrive over time and one server must choose an order, this is the game β€” and β€œwhich rule is best?” always depends on which metric you care about.