Dictionaries · Compare Solutions

Judge — analyse and evaluate L4 Analysis Relations ~4 min

Two vote counters

Two AI-generated programs both try to tally votes into a dictionary. Each is a separate program. Compare them. Which statement is true?

votes = ["yes", "no", "yes"]

# Solution A
tally = {}
for v in votes:
    tally[v] = tally.get(v, 0) + 1

# Solution B
tally = {}
for v in votes:
    tally[v] = tally[v] + 1

Choose one

Why this activity was chosen
  • Bloom level: L4 Analysis: Decide how two solutions to the same problem differ.
  • Block Model level: Relations (step 3 of 4): how parts of the program affect each other: variable updates, function calls, data flow and control flow.
  • Misconception targeted: shown after you answer, so it does not give the answer away.

Generated code often arrives as alternatives. Comparing them means tracing both and finding the exact point where they diverge: analysis rather than recall.

AI’s role here: AI may suggest an input to trace both solutions on. It must not say which one is correct.