FastPrepRepair the Bootloader Program
Problems/Repair the Bootloader Program

Repair the Bootloader Program

Anthropic logoAnthropic● MediumFULLTIMEOAONSITE INTERVIEW
QuestionFunctionExamples

Problem statement

Special thanks: 🌷 A special thank you to our lovely, amazing frenz who shared that this question appeared again on September 10, 2026! ദ്ദി ˉ͈̀꒳ˉ͈́ )✧ 💚

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: add x to the accumulator, then advance to the next instruction.
  • next x: ignore x and advance to the next instruction.
  • jump x: move the program counter by x.

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[]) → int

Examples

Example 1

instructions = ["plus +1","next +0","jump -1","plus +3"]return = 4

The 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

  • Fair Coin from a Biased CoinPHONE SCREEN · Seen Nov 2026
  • Crawl Same-Hostname URLs ConcurrentlyPHONE SCREEN · Seen Oct 2026
  • Longest-Match Tokenizer with Unknown SymbolsONSITE INTERVIEW · Seen Oct 2026
All Anthropic interview questionsSee Anthropic hiring insights
Saved
class Solution {
    public int repairBootloader(String[] instructions) {
      // write your code here
    }
}
Checking account…