Hardware interview practice
Verify signed maximum-product ranges
Implement an exhaustive signed oracle, tagged response checker, and core protocol assertions for an accelerator that returns the maximum product over every nonempty contiguous factor range.
Reviewed example
Work through one case
Input
signed factors=[-2,3,-4]Expected output
maximum_product=24; start=0; end=2The full range product is positive 24 and exceeds every shorter range; widened signed arithmetic avoids truncation.
What to cover
Requirements
- Use an independent O(n squared) exhaustive oracle with a full-width signed product rather than duplicating the DUT's running maximum/minimum algorithm.
- For equal products, select the lowest start and then the lowest end; reject counts outside 1 through 12 with zeroed results.
- List zero, plus/minus one, signed extrema, alternating signs, repeated products, and invalid counts as targeted follow-up stimulus.
- Match responses by ID under independent backpressure, flush pending IDs on reset, and detect unknown, duplicate, or missing responses; explain why a generation field or ID quarantine is needed to identify an old response after ID reuse.
- Assert payload stability and legal returned ranges; identify sign pattern, winning range, tie type, arithmetic boundary, response order, and reset as follow-up coverage dimensions.
