In this Code.org challenge, a Star Wars droid — BB-8 — has fallen to pieces, and its broken parts (scrap metal) are scattered across a grid. The mission: write code that rolls BB-8 around to collect its own parts so it can fix itself, "like fixing a car." Eon points out BB-8 is the round, "snowman"-shaped robot — older than the BD-1 droid from the game he plays, "the Jedi one." Then he and his dad get coding.
Driver and navigator
Just like last lesson, they run it as a pair. Eon is the driver — he writes the code and works the mouse and keyboard. His dad is the navigator — he thinks ahead, spots bugs, and keeps them on track. As Eon explains it: the driver can "focus on writing code and driving," while the navigator is "thinking, navigating, and finding bugs." Two jobs, one team — that's how real programmers work together.
Count the squares — don't guess
The first part sits a few squares to the east. BB-8 dashes in (3… 2… 1… dash!), and now Eon has to tell it how far to roll. He tries to eyeball it: "One, two." His dad stops him — "No, no, count again." They recount together: "One, two, three."
Here's the trick Eon learns: use your mouse to count the squares instead of guessing. Hover and tap across each square — one, and two, and three — and now you know the number. On a grid, a wrong count is a wrong program. Counting carefully is part of coding.
When to loop — and when NOT to
Eon's first instinct is to stack a "go east" block for every single square. His dad points him at the smarter tool — the "repeat" machine (a loop):
When a move happens multiple times, don't stack the same block over and over — drop it inside repeat N times.
So for three squares east, Eon wraps "go east" in a repeat 3. One small loop does the work of three blocks.
But the real lesson comes on the next, harder part. This one needs BB-8 to go east twice, so Eon almost types "repeat 3" again. His dad catches it: "Remember to change how many times — repeat twice, two, not three." The number inside the loop has to match the squares you actually counted.
Then the sharpest insight of all: after the loop, BB-8 only needs to move one more square east to reach the part. Eon starts to wrap that in a repeat too — and his dad says don't. "You don't even need to repeat, because it's just one step." A loop is for doing something more than once. A single move is just a single block. Knowing when not to loop is as important as knowing when to.
Run the route in your head first
Before placing blocks, Eon's dad shares his favorite tip — "like running a simulation in your brain." Imagine BB-8 is already standing at the start, then ask which way to go.
He shows that there are many routes to the same part. You could go down, down, right… or right, down, down… and those two are exactly the same distance. The goal is the most efficient path — "the closest one" — so you avoid silly detours like down, right, up that waste steps. Eon also discovers you can mix directions inside one loop — telling BB-8 to head east and south within the same repeat instead of writing them out separately.
When they finally hit Run, BB-8 rolls through the path, snaps up its parts, and makes a noise so funny they crack up — and the droid even smiles at the end. Bonus discovery: if you reset, everything snaps back to its starting spot but your code stays, so you can run it again and hear that goofy beep one more time.
Try it
Open Code.org (totally free — no download). Find a maze or droid level and try this:
- Count first. Use your mouse to count the squares to the goal. Write the number down.
- Loop the repeats. If you'll move the same way several times, wrap it in "repeat N times" — and make N match your count.
- Skip the loop for a single step. If something is just one square away, use one plain move block, no repeat.
- Run it in your head. Before you click Run, picture your character already there and trace the shortest path. Then check: does the screen match your plan?
