Workshop index · Download all examples and lessons
Review A
With capacity 10, booked 8, and requested 2, the baseline returns confirmed with booked 10. The proposed patch returns sold_out with booked 8. Exact-fill bookings are explicitly permitted by the contract. Changing >= to > restores the intended boundary.
A suitable comment:
Required: this rejects a request for exactly the remaining seats. For example, capacity 10 / booked 8 / requested 2 now returns
sold_out, although the contract permits confirming that request. Please use a strict comparison and add an exact-fill regression test.
The mutation claim is false: subtraction computes a local numeric value; neither implementation writes shared state. The variable-name suggestion is optional. The current name is clear in this small function, so omitting that comment is reasonable.
The public tests pass because none covers a successful exact-fill booking. The author checks in solutions/tests/ explicitly demonstrate that gap. In a real patch, the regression test should assert the correct behaviour and fail on the defective candidate. Our author checks instead assert the known defective output to validate that the exercise still contains its intended teaching case.
Review B
Approve under the stated integer-input contract. For integer quantities, requested < 1 and not (requested > 0) identify the same invalid values. The TypeScript equivalents have the same result over this domain. Both implementations preserve the order of validation and capacity checks.
The AI’s fractional-input observation concerns inputs excluded by the contract. It would be relevant if a real caller could pass a fractional quantity: neither language’s annotation enforces runtime integer validation. Here, that caller guarantee is supplied explicitly. Approval rests on the specified domain, not on an assumption that types validate everything.
Self-assessment
- Did you establish expected behaviour before reading the AI response?
- Did you reproduce the boundary failure with exact inputs and outputs?
- Did you reject the mutation claim by reading the code?
- Did you approve the valid refactor without manufacturing a blocker?
- Did your comments explain impact without dumping the full AI response?