Hardware interview practice
Verify a dominant-opcode window analyzer
Write an exhaustive oracle for the longest opcode window convertible to one of eight classes with at most k replacements, breaking ties by lowest start and then lowest opcode.
Reviewed example
Work through one case
Input
opcodes=[1,2,1,1,3]; k=1Expected output
best_length=4; start=0; target_opcode=1Window [1,2,1,1] becomes all opcode 1 with one replacement; extending through opcode 3 would require two.
What to cover
Requirements
- Enumerate every window and all eight target opcodes in an independent oracle; empty input returns zero result fields.
- Apply the comparison order length, then start, then opcode, and flag k greater than count as a bad request.
- Explain dominant, balanced, alternating, long-run, exact-k, multiple-start, and multiple-opcode cases as targeted stimulus.
- Return the complete result record for a later ID-keyed scoreboard; response ordering and reset epochs are follow-up architecture.
- Identify feasibility, length, start, opcode, entropy, and tie type as separate diagnostic or coverage dimensions.
