Interview Brain Teasers Medium 3 min

You have 10 identical batteries, but 2 are dead. A device requires two working batteries. What is the minimum number of pairs you need to test in the worst case to guarantee finding a working pair?

Hint
Think in terms of how many pairs can contain the two dead batteries.

Answer

4 pairs.

Explanation

A systematic pairing strategy can guarantee success by testing disjoint pairs. Since only two batteries are dead, among five disjoint pairs at least three pairs contain two working batteries or one working and one dead; testing strategically can guarantee a working pair within four tests.

Step-by-Step Solution

Create disjoint pairs.
Because only two batteries are dead, at least three pairs contain two working batteries.
A worst-case sequential test requires at most four pair tests.
6 puzzles