Code Crew G2 / Week 03 / Monday
1/6
Week 03 Β· Count With a Box

Monday

A box that counts
// A steps box counts every round
⏱ about 15 min
Rocket, Raven, and Nova the drone-bird together

Welcome back, Code Crew!

Raven finds one more box in the auto-pilot.

Its name tag says steps.

Nova watches the steps box during a test flight.

Each time the ship moves, steps goes up by one.

The steps box is counting!

Rocket wants to learn how a box can count.

WARM-UP: TWO-BOX POWERS
  • Read each little program.
  • Tap what Nova says.
set height to 3
set speed to height
say speed
?
set height to 6
lower height by 2
say height
?
set height to 5
set speed to height
lower height by 2
say speed
?
A test ship moves right 3 steps and the steps box holds 3

A box that counts

The ship moves one step at a time.

After each step, the box adds one.

Three steps, so the box holds 3.

A memory box named steps holding 0

Start at zero

Set steps to 0 starts the count.

Zero means nothing counted yet.

Change steps by 1 counts one more.

set steps to 0
move right
change steps by 1
move right
change steps by 1
say steps
Raven the explorer with her wrist computer

What do you notice?

Move, count. Move, count.

Only the change lines touch the box.

So Nova says 2.

COUNT THE STEPS
  • Count the change lines.
  • Tap what Nova says.
set steps to 0
move right
change steps by 1
say steps
?
set steps to 0
change steps by 1
change steps by 1
change steps by 1
say steps
?
set steps to 2
change steps by 1
change steps by 1
say steps
?

Build a one-step counter.

Nova moves one step and says 1.

BUILD A ONE-STEP COUNTER
  • Read each card.
  • Start at 0 before you count. Say last.
1line 1
2line 2
3line 3
4line 4
aftersteps holdstrue?
line 10?
line 21?
line 31?
line 42?
line 52?
Rocket the inventor holding his engineering tablet

So many lines!

Counting ten steps takes so many lines.

Is there a faster way?

We find out tomorrow!

Your box can count!

Set steps to 0 starts the count.

Change steps by 1 counts one more.

Great work, Crew!