Curriculum

Curriculum

Build a Classroom Quiz Scorer

Scenario

Use the answer key [A, B, C]. An answer earns one point if it matches at the same position. Return the count, and report invalid input when lengths differ.

Selected choicePick a choice below
Result—

Try it yourself

Predict each outcome, then turn the examples into tests before you code.

Reveal the explanation
  1. [A, X, C]

    Expected 2. The first and third answers match.

  2. [C, A, B]

    Expected 0. None matches at its position.

  3. [A, B]

    Expected invalid input. The answer count differs from the key.

Draw the length check before the loop. Ask the agent to return only the count or invalid-input result, then inspect how it matches positions and stops.

Download shared test cases

Your turn

Build the scorer and test partial matches, a shifted array, and unequal lengths.

Common mistake Counting an answer that occurs elsewhere in the key.

Check your work

The results are 2, 0, and invalid input for the three given examples.

Project brief

Basic
Trace the given answers with a table of position, expected letter, actual letter, and running score.
Intermediate
Implement the scorer and test partial matches, all incorrect answers, and unequal lengths.
Stretch
Add empty input and a valid all-correct example. Reuse those cases when porting the scorer to a second language.

What to hand in

Include your diagram, expected-result table, code, actual test output, and the commit or diff you reviewed.

Review criteria

  • Logic · Your diagram shows every required path and boundary.
  • Verification · The tests exercise the stated acceptance cases and the recorded results match the code.
  • Review · The change is focused and you can explain the decision it implements.