Teacher answer key

Arithmetic and Input

Gather four kinds of evidence: prediction of relevant state; behavior across varied cases including boundaries; explanation using trace/state evidence; and a reasoned correction of one mismatch. Mark each as emerging, with support or independent using paper or your school’s existing approved process. A challenge pass is machine-behavior evidence, not proof of authorship or complete mastery. Accept equivalent correct programs; the public key is a model, not the only possible answer.

Public teaching material. Solutions are examples; equivalent correct programs may also pass the actual checks.

4. Emoji Math

Combine addition, subtraction, and multiplication as ordered steps.

Open this lesson →

1. Predict and trace

Before running the Try program, predict its output and trace the first three executed instructions. Track the relevant registers, flags or memory as needed. Then step the program to compare.

LOAD 10
ADD 5
PRINT
MUL 2
SUB 4
PRINT
HALT

Queue input: None

Initialize memory: All bytes initially zero

Try prediction key

Output: 15, 26

InstructionPC beforePC afterR0 beforeR0 afterRelevant stateOutput
LOAD01010{"registers":[10,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[]}None
ADD121015{"registers":[15,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[]}None
PRINT231515{"registers":[15,0,0,0,0,0,0,0],"flags":{"zero":false,"negative":false,"overflow":false},"sp":255,"stack":[],"callStack":[],"loopStack":[],"memoryReads":[],"memoryWrites":[]}15

2. Build and check

Read one integer x and print (x + 5) × 2 − 4. Your program must work for every supplied input, including negative numbers.

Required instruction types: INPUT, ADD, MUL, SUB

Example challenge solution

INPUT
ADD 5
MUL 2
SUB 4
PRINT
HALT

Actual checker fixtures

Case 1
Input
0
Initial memory
All bytes initially zero
Expected output
6
Case 2
Input
-3
Initial memory
All bytes initially zero
Expected output
0
Case 3
Input
12
Initial memory
All bytes initially zero
Expected output
30

3. Explain the machine

Why is MUL after ADD necessary for (x+5)×2−4?

Reasoning and teaching note

Each operation modifies the accumulated result; reversing ADD/MUL changes the expression for most x.