Repair the Bootloader Program
Learn this problemProblem statement
Interview report note: The reports described a bootloader program with plus, next, and jump instructions, plus one swapped next/jump instruction that causes a loop. This practice version is an estimated 90% match for the repair task; the original numeric constraints and the separate loop-reporting output were not shared.
A bootloader executes a list of instructions using a program counter pc and an accumulator that starts at 0. Each instruction contains an operation and a signed integer operand.
Instruction semantics
plus x: addxto the accumulator, then advance to the next instruction.next x: ignorexand advance to the next instruction.jump x: move the program counter byx.
The program terminates normally when the program counter moves past the final instruction. It is looping if it is about to execute an instruction that it has already executed.
Repair rule
Exactly one instruction was corrupted: a next operation was changed to jump, or a jump operation was changed to next. Its operand is still correct. Changing that one operation back makes the program terminate normally.
Repair the corrupted instruction and return the accumulator value after the repaired program terminates.
Function
repairBootloader(instructions: String[]) → intExamples
Example 1
instructions = ["plus +1","next +0","jump -1","plus +3"]return = 4The original program repeats instructions 1 and 2. Changing instruction 2 from jump -1 to next -1 lets execution reach the final plus +3 instruction and terminate with accumulator 1 + 3 = 4.
More Anthropic problems
- Banking System, Part 1: Accounts and TransfersOA · Seen Jul 2026
- Banking System, Part 2: Top SpendersOA · Seen Jul 2026
- Banking System, Part 3: Scheduled PaymentsOA · Seen Jul 2026
- Banking System, Part 4: Merging and Balance HistoryOA · Seen Jul 2026
- Convert Stack Samples to Trace EventsPHONE SCREEN · Seen Jul 2026
- Cloud Storage SystemOA · Seen Jun 2026
- Normalize a DNS Domain NameOA · Seen May 2026
- Worker Management, Part 4: Double-Paid IntervalsOA · Seen May 2026