The Scala grade-school exercise tests 7 cases, while problem-specifications has 20. The gap can’t be closed just by adding cases: the track’s School behaves differently from the spec.
addreturnsUnit. The spec expectstruewhen a student is enrolled andfalsewhen they are rejected (5 cases check this).- Duplicates are accepted. The spec rejects a student added twice, whether to the same grade or to another one. Today
grade(2)can returnVector(Blair, James, James, Paul). grade(n)keeps insertion order. The spec expects names sorted alphabetically. Only the extrasortedmethod sorts, and it has no canonical counterpart.
Any fix changes the stub’s API (add, and probably db/sorted), so existing solutions would stop passing.
Options:
- A. Adopt the canonical contract.
add(name, grade): Boolean, reject duplicates, sort each grade, drop or reworksorted/db. Covers all 20 cases. - B. Keep the current contract. Mark the incompatible cases
include = falsewith a comment saying the track’sSchoolpredates the canonical one, and sync the cases that fit. Nothing breaks. - C. Middle ground. Reject duplicates and sort grades, but keep
addreturningUnit. This still breaks solutions that rely on duplicates, and still skips the 5addcases.
My preference is A: the exercise is about keeping a valid roster, and today it lets you enrol the same student twice. B is the fallback.
Which would you pick — A, B or C? A one-letter reply is enough; a sentence on why is even better. It’s especially helpful to hear from anyone who has solved or mentored this exercise.