Safe Cracker's Worst Case

maximum attempts for three number safe is a medium quant interview question on Brain Teasers.

Difficulty Medium Topic Brain Teasers

This brain teaser is about opening a mechanical safe with a three-number combination, where the dial can point to any of several marked positions but the correct sequence is unknown. The candidate must reason about the worst-case number of distinct full attempts needed, given how the lock behaves and when it reveals success. The structure of the dialing sequence, the ranges allowed for each number, and the fact that the mechanism only opens at the very end all matter. The challenge is to understand how these design details constrain what information each failed attempt gives you, and how that changes the total search effort in the worst case.

Solving it leans heavily on systematic counting, worst-case analysis, and careful interpretation of process feedback. The interviewer is looking for someone who can model the state space of possible combinations, distinguish between independent and dependent stages, and avoid naively multiplying everything when that is not justified. Clear reasoning about when information is actually revealed, and how that affects the remaining uncertainty, is crucial. They also watch for precision in handling off-by-one issues and boundary cases in the range of valid dial positions.

What it tests

Problems involving sequential unlocking or staged processes often appear to require enumerating all possible combinations for each stage, but the true complexity depends on when the system reveals success or failure. The key is to recognize whether later stages are dependent on earlier choices or if, once a certain threshold is reached, the remaining steps can be brute-forced or bypassed. In many physical or algorithmic systems, the design allows for partial progress to be tested, so the total number of attempts is governed by the point at which feedback is given. This principle holds because the process is not strictly all-or-nothing: once enough correct information is input, the remaining uncertainty can often be resolved with minimal additional effort.

Practise this question with written feedback, or hear it in a spoken mock interview.

Get started free