Puzzle Details :
You have a Torch that takes 2 working batteries. You have 8 batteries but only 4 of them work. What is the fewest number of pairs you need to test to guarantee you can get the Torch on?
This problem does definitely raise a lot of confusion in the mind, about the approach required to solve the problem with the correct answer in the fewest number of pairs. Give it a try before checking the solution.
Let us call the batteries as B1,B2,B3,B4,B5,B6,B7,B8.
The torch will work when both the batteries are working, it will not work if any of the batteries are faulty.
In the best case, if we take 2 pairs of batteries and put them in slot 1 and slot 2, test them out, if working then fine, else take another two and test them out and continue doing so till you get the correct pair.
if we are lucky in these 4 turns, Torch will work, but let’s say we were most unlucky and it did not work all 4 times.
Also, The whole objective is to find the solution for the worst-case scenario and not for the best case.
Now let's group the batteries into two groups of 4 (slot 1 and slot 2). There can be these cases in groups of 4
If All 4 batteries are working => take any pair and we will get the working battery in just 1 chance
If Only 3 batteries are working => we will get working batteries in max 2 picks
If Only, 2 batteries are working => the scenario becomes tricky, because this will open up multiple possibilities and end up in more iterations to find the pair to switch on Torch. if only one battery is working in the group then scenarios become more complex.
Hence grouping batteries into two groups with 4 batteries each is not the correct approach.
Now I will explain the most efficient way of finding the solution to this puzzle.
We know that Out of the 8 batteries, only 4 are in working condition.
We need 2 good batteries to run.
Let us try to divide the 8 batteries into a group of 3.
8 = 3 + 3 + 2.
Where group1 and group 2 contain 3 batteries and group3 contains 2 batteries.
Group 1 = 3 batteries,Group 2 = 3 batteries,Group 3 = 2 batteries.
By grouping the batteries like this we are making sure that at least one of the group has two working batteries.
this is because, there are 4 working batteries and only 3 groups, going through logic there must be at least 2 batteries in any one of the groups. Also by grouping like this, we are reducing the number of combinations required to find the working pair for the battery.
Now, let's find, How many combinations are possible for each group?
Let's go one by one
in Group 1: B1 B2 B3.
Possible combinations are → B1B2, B2B3, or B1B3.
hence Total combinations = 3.
In Group 2: B4 B5 B6.
Possible combinations are → B4B5, B5B6, or B4B6.
Total combinations = 3.
In Group 3: B7 B8.
Possible combinations → B7B8.
Total combinations = 1.
We know that at least one of the groups has two working batteries, by logic any one of these combinations must work.
Adding all the combinations = 3 (Group 1) + 3 (Group 2) + 1 (Group 3) =7. we get 7.
Hence, the minimum number of trails needed = 7.
let us summarize
break the batteries into 3 groups: Two groups of 3 batteries and one group of 2 batteries. By doing this you guarantee that one of the groups has 2 working batteries. Both the groups of 3 have 3 possible combinations of 2 batteries and the group of 2 only has 1 combination. So, 3 + 3 + 1 = 7 tries at most to find two working batteries.
No comments:
Post a Comment