asked 180k views
4 votes
The Faulty Combination Lock

A combination lock with three dials, each numbered 1 through 8, is defective in that you only need to get two of the numbers right to open the lock. (For example, suppose the true combination is 4-2-7. Then 4-2-7 would open th lock but so would 4-2-5, 4-2-2 , 8-2-7 or 4-6-7. But not 2-4-7)

What is the minimum number of (Three-number) combinations you need to try in order to be sure of opening the lock?

1 Answer

3 votes

Answer: 491

============================================

Step-by-step explanation:

Let's go with the example given to us. Let's say the correct lock combo is 4-2-7.

If we get the first two digits right, then we have 8 choices for the third digit since we pick from between 1 and 8 inclusive. There are 8 combos of the form 4-2-x.

The same goes for stuff of the form 4-x-7 and x-2-7.

There appear to be 8+8+8 = 24 different combos that will open this faulty lock. However, we must subtract off 2 because we've triple counted "4-2-7" when adding up those 8's.

In reality there are 24-2 = 22 different combos that will open the faulty lock.

There are 8^3 = 512 different combos total. That gives 512-22 = 490 combos that do not open the lock.

If the person is very unlucky, with the worst luck possible, then they would randomly try all of the 490 combos that don't work.

Attempt number 491 is when they'll land on one of the 22 combos that do work.

answered
User Bartek Jablonski
by
8.5k points