Code Crew G2 / Week 04 / Monday
1/6
Week 04 Β· Loop Logbooks

Monday

A logbook for every lap
// Track a box through every lap
⏱ about 15 min
Rocket, Raven, and Nova the drone-bird together

Welcome to Week 4, Crew!

The test ships are flying again this week.

The auto-pilot flies each ship in laps.

Nova writes down every lap in a logbook.

Raven wants to read those logbooks.

Maybe the logbooks hold a clue about the drop.

First, the crew practices with small loops.

WARM-UP: COUNT WITH A BOX
  • Read each little program.
  • Tap what the steps box holds.
set steps to 0
repeat 3 times:
change steps by 1
?
set steps to 2
repeat 3 times:
change steps by 1
?
A program with a repeat line, two lines inside the loop, and a stop line

Lines inside the loop

The lines under repeat are inside the loop.

Nova runs them once every lap.

Stop ends the loop.

So Nova lands once, at the end.

set steps to 0
repeat 3 times:
change steps by 1
move right
stop
land
A lap logbook: steps holds 0, then 1, 2, and 3

A logbook for every lap

A loop logbook has one row per lap.

After lap 1, steps holds 1.

After lap 3, steps holds 3.

WHERE DOES STEPS END?
  • Follow the loop lap by lap.
  • Tap the answer.
set steps to 0
repeat 4 times:
change steps by 1
?
set steps to 5
repeat 2 times:
change steps by 1
?
set steps to 1
repeat 2 times:
change steps by 2
stop
say steps
?

Now build a loop flight.

Nova moves right 3 times.

Then Nova lands, just once.

BUILD A THREE LAP FLIGHT
  • Stop ends the loop.
  • Land goes last.
1line 1
2line 2
3line 3
4line 4
5line 5
6line 6
Raven the explorer with her wrist computer

What do you notice?

Start at 0, and steps matches the lap.

Start at 2, and steps is 2 ahead.

Always check where the box starts.

set steps to 2
repeat 3 times:
change steps by 1
move right
aftersteps holdstrue?
start2?
lap 13?
lap 25?
lap 35?

You tracked every lap!

Lines under repeat run every lap.

A logbook has a row per lap.

Check where the box starts.

Great work, Crew!