
Torch and 8 Batteries Puzzle Think outside the box
video description
I used probabilistic approach.
Total no. of combinations to select 2 batteries = (choices for 1st x choices for 2nd)/2(as order doesn't matter) = (8 x 7)/2 = 28.
Probability of selecting both bad batteries = 1st choice (4 out of 8) x 2nd Choice (3 out of 7) = (4/8)x(3/7) = 3/14.
Probability of selecting both good batteries will be same but probability of selecting both bad batteries is used as we want to calculate the maximum tries of sure failure before being successful.
Maximum tries of selecting both bad batteries = respective probability - total changes = 28-3/14 = 6.
Now below co-relation is my assumption and this approach to solve the problem can break here if the assumption is wrong. (anybody good with probabilities can provide more insight)
Minimum tries for selecting both good batteries = 1 + Maximum tries of selecting both bad batteries = 7.
In same way we can also say that maximum tries of selecting both good batteries = 1 + Maximum tries of selecting at least one bad battery = 1 + 28(1 - 3/14) = 23
This approach doesn't explain the algorithm of how to achieve the result, but it tries to explain the upper and lower bounds (if assumption is correct)
Date: 2023-11-15
Related videos
Comments and reviews: 29
David
1 attempt is the correct answer. The rules stated the torch requires 2 batteries to light up, it didn't state needs 2 charged batteries to light up. So the first 2 batteries you put in should light up the torch, otherwise this problem is worded incorrectly. For this problem to be worded correctly, it would have to state that 2 charged batteries in the torch simultaneously is the ONLY combination that will light up the torch. The rules also state that we (the people trying to solve this problem) don't know which 4 batteries are charged, but it doesn't say anything about us having knowledge of which (less than 4) batteries are charged. For example, suppose someone knows 3 of the 4 charged batteries. They don't know which 4 are charged so they are not breaking the rules. They only know which 3 are charged. In that case, they can get the torch to light on the first attempt. This is a classic example of a VERY badly worded problem. They also didn't clearly define what an attempt is. Also, the answer of 7 given here can be argued as incorrect, as it assumes that the person using the solution given in this video will not get confused and repeat an already attempted wrong combination (which would count as another attempt.
reply
1 attempt is the correct answer. The rules stated the torch requires 2 batteries to light up, it didn't state needs 2 charged batteries to light up. So the first 2 batteries you put in should light up the torch, otherwise this problem is worded incorrectly. For this problem to be worded correctly, it would have to state that 2 charged batteries in the torch simultaneously is the ONLY combination that will light up the torch. The rules also state that we (the people trying to solve this problem) don't know which 4 batteries are charged, but it doesn't say anything about us having knowledge of which (less than 4) batteries are charged. For example, suppose someone knows 3 of the 4 charged batteries. They don't know which 4 are charged so they are not breaking the rules. They only know which 3 are charged. In that case, they can get the torch to light on the first attempt. This is a classic example of a VERY badly worded problem. They also didn't clearly define what an attempt is. Also, the answer of 7 given here can be argued as incorrect, as it assumes that the person using the solution given in this video will not get confused and repeat an already attempted wrong combination (which would count as another attempt.
reply
David
How can this solution presented here be -proven- as optimal? Do you just enumerate all the grouping possibilities and just count up the one with the least number of worst case attempts? What if the problem was so large that enumerating them all was not practical? For example, if you had 80 identical looking batteries and exactly 40 of them were charged, but which 40 was unknown? That problem is not practical to solve by enumerating all possible groupings, so I am looking for a more -generic- solution to this type of problem. Will the solution always have the maximum number of groups of 3, then a -remainder- group? For example, 80 batteries would have 26 groups of 3 (78 batteries, and a -remainder- group of 2 batteries? What if we instead had 79 batteries with 39 charged?
reply
How can this solution presented here be -proven- as optimal? Do you just enumerate all the grouping possibilities and just count up the one with the least number of worst case attempts? What if the problem was so large that enumerating them all was not practical? For example, if you had 80 identical looking batteries and exactly 40 of them were charged, but which 40 was unknown? That problem is not practical to solve by enumerating all possible groupings, so I am looking for a more -generic- solution to this type of problem. Will the solution always have the maximum number of groups of 3, then a -remainder- group? For example, 80 batteries would have 26 groups of 3 (78 batteries, and a -remainder- group of 2 batteries? What if we instead had 79 batteries with 39 charged?
reply
Ivan
Ok. Didn't look at the solution yet. I'm down to 6 tests (worst case scenario. I'm sure I'm missing something!
Here is my thought process:
Try each one in pairs (1, 2) - (3, 4) etc. if they all fail it mains each pair is made of 1 empty and 1 charged battery. if it weren't the case at least one pair would have worked (4 attemps)
Next do (1, 3) if it fails try (2, 3) If it fails then (1, 4) are both charged (+2 attempts)
I can't believe I need so many tries. I must be wrong somewhere - Let me look at the solution!
WHAT? Odd grouping? I didn't need that. What did I miss?
Ok Doing the (1, 3) test and it fails does it guarantee (2, 4) will also fail? Nope. That's what I did wrong. 3+3+2 is obviously the right answer. I'm stoopid!
reply
Ok. Didn't look at the solution yet. I'm down to 6 tests (worst case scenario. I'm sure I'm missing something!
Here is my thought process:
Try each one in pairs (1, 2) - (3, 4) etc. if they all fail it mains each pair is made of 1 empty and 1 charged battery. if it weren't the case at least one pair would have worked (4 attemps)
Next do (1, 3) if it fails try (2, 3) If it fails then (1, 4) are both charged (+2 attempts)
I can't believe I need so many tries. I must be wrong somewhere - Let me look at the solution!
WHAT? Odd grouping? I didn't need that. What did I miss?
Ok Doing the (1, 3) test and it fails does it guarantee (2, 4) will also fail? Nope. That's what I did wrong. 3+3+2 is obviously the right answer. I'm stoopid!
reply
JLvatron
Hi Ammar, your solution used 7 attempts but you can do it in 6.
Let's label attempts A to F as the following battery pairings:
A= 1&2
B= 3&4
C= 1&3
D= 2&4
E= 5&6
F= 7&8
If attempts A&B don't work, it tells us batteries 1 - 4 have minimum 2 bad batteries.
Next, if C&D fail, then it's minimum 3 bad batteries in group 1 - 4.
This tells us group 5 - 8 has a minimum of 3 Good batteries, so we shift focus here.
If attempt E fails, this guarantees batteries 7&8 are good, so attempt F will work.
reply
Hi Ammar, your solution used 7 attempts but you can do it in 6.
Let's label attempts A to F as the following battery pairings:
A= 1&2
B= 3&4
C= 1&3
D= 2&4
E= 5&6
F= 7&8
If attempts A&B don't work, it tells us batteries 1 - 4 have minimum 2 bad batteries.
Next, if C&D fail, then it's minimum 3 bad batteries in group 1 - 4.
This tells us group 5 - 8 has a minimum of 3 Good batteries, so we shift focus here.
If attempt E fails, this guarantees batteries 7&8 are good, so attempt F will work.
reply
Kenneth
I think you can take two charged batteries with 6 attempts. Divide the batteries with 2 pairs. Just like you said, the worst case scenario would be each pair will only have 1 charged battery. Let's name each pairs like:
AB, CD, EF, GH
That would be 4 attempts already.
If that's the case, take 2 pairs next. Say AB and CD, then switch one battery from each pair to become AC and BD. With this new pair, at least one pair will have both batteries charged, hence additional 2 attempts.
reply
I think you can take two charged batteries with 6 attempts. Divide the batteries with 2 pairs. Just like you said, the worst case scenario would be each pair will only have 1 charged battery. Let's name each pairs like:
AB, CD, EF, GH
That would be 4 attempts already.
If that's the case, take 2 pairs next. Say AB and CD, then switch one battery from each pair to become AC and BD. With this new pair, at least one pair will have both batteries charged, hence additional 2 attempts.
reply
Blazemaster
I got 7 attempts using the approach of splitting in 4 groups of 2, after testing each pair (4 attempts) and assume that none of them work, you know that each pair has one charged battery and one that isn't, take two pairs and switch the batteries, if it still doesn't work, you know that the batteries you switched are in the same state, try out those two batteries and if that doesn't work, it is certain that the other two will be charged. This approach adds up to a total of 7 attempts
reply
I got 7 attempts using the approach of splitting in 4 groups of 2, after testing each pair (4 attempts) and assume that none of them work, you know that each pair has one charged battery and one that isn't, take two pairs and switch the batteries, if it still doesn't work, you know that the batteries you switched are in the same state, try out those two batteries and if that doesn't work, it is certain that the other two will be charged. This approach adds up to a total of 7 attempts
reply
Ryad
5, 5 moves dammit. OK Ammar, you're fired. You took a whole extra 10 seconds with 2 extra attempts. You can do it in 5 moves. b1 +b2, b1+b3, b1+b4. after 3 moves, worst case is all 4 are flat then we know b5-8 are charged. But perhaps we had a charged one in testing. B1+ b2 and b2 is charged. Set aside b2. B1+b3, 4, 5flat then 678 are charged so next step, b2 and b6, 7 or 8. Total of 5 moves worst case scenario. Like we can get it in 4 but lets be conservative here.
reply
5, 5 moves dammit. OK Ammar, you're fired. You took a whole extra 10 seconds with 2 extra attempts. You can do it in 5 moves. b1 +b2, b1+b3, b1+b4. after 3 moves, worst case is all 4 are flat then we know b5-8 are charged. But perhaps we had a charged one in testing. B1+ b2 and b2 is charged. Set aside b2. B1+b3, 4, 5flat then 678 are charged so next step, b2 and b6, 7 or 8. Total of 5 moves worst case scenario. Like we can get it in 4 but lets be conservative here.
reply
Naoya
Here's how I solved this:
try combinations like 1&2, 3&4, 5&6, and 7&8. If any of these combinations didn't work, the possible case would be either battery of each combination isn't charged. In other words, if you make a group of 4(1, 2, 3, 4, 2 of them are surely charged. So, try combinations of 1&3, 1&4, then 2&4. Now I have tried 7 patterns and found the correct combination.
reply
Here's how I solved this:
try combinations like 1&2, 3&4, 5&6, and 7&8. If any of these combinations didn't work, the possible case would be either battery of each combination isn't charged. In other words, if you make a group of 4(1, 2, 3, 4, 2 of them are surely charged. So, try combinations of 1&3, 1&4, then 2&4. Now I have tried 7 patterns and found the correct combination.
reply
David
Here is another 7 check solution: check 1&2, 3&4, 5&6. If they all fail, then the first three pairs have at least 3 dead batteries. 1&2 has either 2 dead or 1 dead. If 2 dead, then 7&8 are both good. If 1&2 has 1 dead, then 7&8 has at least 1 good. Compare 1&7, 1&8, 2&7, and 2&8. At least one of these pairs must have two good. 7 checks were done.
reply
Here is another 7 check solution: check 1&2, 3&4, 5&6. If they all fail, then the first three pairs have at least 3 dead batteries. 1&2 has either 2 dead or 1 dead. If 2 dead, then 7&8 are both good. If 1&2 has 1 dead, then 7&8 has at least 1 good. Compare 1&7, 1&8, 2&7, and 2&8. At least one of these pairs must have two good. 7 checks were done.
reply
ChillMode
it can be either 1 or 2. 1 if you're very lucky and 2 because on your first try there is a 50% chance of that you get a charged battery. So, keep that, and take another attempt, which will yield another charged battery. Now you have two charged batteries. Put it in and there you have it. Why do we have to overcomplicate it?
reply
it can be either 1 or 2. 1 if you're very lucky and 2 because on your first try there is a 50% chance of that you get a charged battery. So, keep that, and take another attempt, which will yield another charged battery. Now you have two charged batteries. Put it in and there you have it. Why do we have to overcomplicate it?
reply
Ressuu
I found a different strategy: Divide the batteries in four pairs. Then try them all. If none work, it means that each pair HAS to have one charged and one discharged. Then take one pair and switch a battery with another pair twice. After that, the other pair must have two charged batteries. Also yields 7 attempts though.
reply
I found a different strategy: Divide the batteries in four pairs. Then try them all. If none work, it means that each pair HAS to have one charged and one discharged. Then take one pair and switch a battery with another pair twice. After that, the other pair must have two charged batteries. Also yields 7 attempts though.
reply
Araqius
Try 1 2-
Try 2 3-
Try 1 3-
At least two bad battery among 1 2 and 3. -
Try 4 5-
At least one bad battery among 4 and 5. -
Try 6 7-
At least one bad battery among 6 and 7. -
Now, we know 8 is a good one. -
Try 8 with 4. -
Now we know 4 is bad. -
Try 8 with 5 and it will work.
reply
Try 1 2-
Try 2 3-
Try 1 3-
At least two bad battery among 1 2 and 3. -
Try 4 5-
At least one bad battery among 4 and 5. -
Try 6 7-
At least one bad battery among 6 and 7. -
Now, we know 8 is a good one. -
Try 8 with 4. -
Now we know 4 is bad. -
Try 8 with 5 and it will work.
reply
Khanbabaie
I think you are wrong
split batts in 2, 2 and 4 groups
check 2 batteries group first(2 att)
in bad scenario in 2's group are 2 good batteries
now we now in 4 else batteries. we have 2 good batteries and need to check 4 attemp to check all possibilities
so optimal answer is 6 attempts
reply
I think you are wrong
split batts in 2, 2 and 4 groups
check 2 batteries group first(2 att)
in bad scenario in 2's group are 2 good batteries
now we now in 4 else batteries. we have 2 good batteries and need to check 4 attemp to check all possibilities
so optimal answer is 6 attempts
reply
Peter
This is a demonstration of the difference between software writers and actual engineers. In the real world of engineers the train wrecks once, then you have to go figure out what happened and how to keep it from happening again. In the software world, you just back the train up and try again.
reply
This is a demonstration of the difference between software writers and actual engineers. In the real world of engineers the train wrecks once, then you have to go figure out what happened and how to keep it from happening again. In the software world, you just back the train up and try again.
reply
Cricket
50% of batteries are faulty. so even if we assume first set of 50%, i. e first 4 batteries are faulty, then we get the right answer in 6th attempt
1-2 -- fault
2. 3- fault
3-4 fault
1-4 fault
4-5 fault
then next attempt i. e 6th one has to be right
like 5-6 right
reply
50% of batteries are faulty. so even if we assume first set of 50%, i. e first 4 batteries are faulty, then we get the right answer in 6th attempt
1-2 -- fault
2. 3- fault
3-4 fault
1-4 fault
4-5 fault
then next attempt i. e 6th one has to be right
like 5-6 right
reply
Prathosh
There is a 6 Test Solution
Step 1:
Take 4 pairs and test it. Worst case scenario is each has one dead battery
AB, CD, EF, GH
Step 2:
Take two pair and switch their pair and test them
This should only two dead battery and one test must work
AC, BD
4+2=6
reply
There is a 6 Test Solution
Step 1:
Take 4 pairs and test it. Worst case scenario is each has one dead battery
AB, CD, EF, GH
Step 2:
Take two pair and switch their pair and test them
This should only two dead battery and one test must work
AC, BD
4+2=6
reply
museruse1
To optimize it further, would the ordering make a difference? I mean I would want to try out Group 3 (containing 2 batteries) first. The worst case would still be at 7 attempts, but would the better cases be better optimized? I am feeling too lazy to solve it for all cases -
reply
To optimize it further, would the ordering make a difference? I mean I would want to try out Group 3 (containing 2 batteries) first. The worst case would still be at 7 attempts, but would the better cases be better optimized? I am feeling too lazy to solve it for all cases -
reply
Sahil
In your attempt 1 i. e. the case where you took two batteries in one pair, thereafter the first 4 worst cases you randomly chose any two pair then there will be 6 cases as 4C2 out of which is the correct combination so we will get 10 as a result in your first cases. am I right?
reply
In your attempt 1 i. e. the case where you took two batteries in one pair, thereafter the first 4 worst cases you randomly chose any two pair then there will be 6 cases as 4C2 out of which is the correct combination so we will get 10 as a result in your first cases. am I right?
reply
Manu
Out of the box: lift the batteries from there end terminal and bang it vertically on the ground if it bounces back its uncharged or dead and the batteries that while least bounced are charged thus we can conclude simply without putting combinations in the torch-
reply
Out of the box: lift the batteries from there end terminal and bang it vertically on the ground if it bounces back its uncharged or dead and the batteries that while least bounced are charged thus we can conclude simply without putting combinations in the torch-
reply
James
Note that they said dead batteries, not defective or discharged batteries. Bounce the disposable batteries and try the ones with the least bounce! This works because discharging batteries produces some hydrogen, which pressurizes a dead battery.
reply
Note that they said dead batteries, not defective or discharged batteries. Bounce the disposable batteries and try the ones with the least bounce! This works because discharging batteries produces some hydrogen, which pressurizes a dead battery.
reply
username7763
You should not mix charged and uncharged cells like that. Use a meter and test them. Ideally you should test the cells with a load, however if they are cells that are fully charged and fully uncharged, a simple test of voltage will work.
reply
You should not mix charged and uncharged cells like that. Use a meter and test them. Ideally you should test the cells with a load, however if they are cells that are fully charged and fully uncharged, a simple test of voltage will work.
reply
Vella
As the torch already have 2 charged batteries in it we put on battery out and try other batteries one by one
Worst case - first 4 with discharge battery and it will light up in the 5th attempt and the rest of the left batteries are charged
reply
As the torch already have 2 charged batteries in it we put on battery out and try other batteries one by one
Worst case - first 4 with discharge battery and it will light up in the 5th attempt and the rest of the left batteries are charged
reply
xevira
one could argue that the 7th attempt isn't a real attempt because at that point, you -KNOW- battery 7 and 8 are both good batteries, therefore it isn't an attempt. You are just using working batteries at this point with no need to test them.
reply
one could argue that the 7th attempt isn't a real attempt because at that point, you -KNOW- battery 7 and 8 are both good batteries, therefore it isn't an attempt. You are just using working batteries at this point with no need to test them.
reply
Satyam
32, fixing 1-8 postions and 1-8 battery fixed and fixed one is charged as you make pair, (1-8): 2 pairs so total 4-8=32 / -though 16 can be one apporach-/, but we have no information whc is charged. possible number. if optimal then 16 is ans.
reply
32, fixing 1-8 postions and 1-8 battery fixed and fixed one is charged as you make pair, (1-8): 2 pairs so total 4-8=32 / -though 16 can be one apporach-/, but we have no information whc is charged. possible number. if optimal then 16 is ans.
reply
Anton
I'm sorry, but if we are talking about -out of the box- - you can use your tongue to check the battery before use. Touch both poles by your tongue and you feel wich battery is charged/ You have to check 5 times to find. Is it the answer?
reply
I'm sorry, but if we are talking about -out of the box- - you can use your tongue to check the battery before use. Touch both poles by your tongue and you feel wich battery is charged/ You have to check 5 times to find. Is it the answer?
reply
Alphonse
Just use your tongue to check good batteries. Touch one finger on the bottom of the battery and touch tongue on the top of the battery, Very biological method, mother nature voltmeter. Use only the batteries that feels most sour.
reply
Just use your tongue to check good batteries. Touch one finger on the bottom of the battery and touch tongue on the top of the battery, Very biological method, mother nature voltmeter. Use only the batteries that feels most sour.
reply
StoneC0ld5345
Maximum attempts=1.
Test each battery using a battery tester, discard the four dead batteries or put them on a charger and insert two charged batteries into the flashlight.
Hey, he said to think outside the box. ;)
reply
Maximum attempts=1.
Test each battery using a battery tester, discard the four dead batteries or put them on a charger and insert two charged batteries into the flashlight.
Hey, he said to think outside the box. ;)
reply
Mats
The least number is 6. First test in pairs. 1&2, 3&4, 5&6, 7&8. If none light up you have found that each pair has a bad and a good battery. Now test 1&4. If both are bad 2&3 are good. So in worst case you need to try 6 times.
reply
The least number is 6. First test in pairs. 1&2, 3&4, 5&6, 7&8. If none light up you have found that each pair has a bad and a good battery. Now test 1&4. If both are bad 2&3 are good. So in worst case you need to try 6 times.
reply
flowbeus
This puzzle doesn't answer its own question: -What is the least number of attempts you need to make, to ensure it will light up the torch? - There is no proof that you can't do it in 6 or less, just that it works for 7.
reply
This puzzle doesn't answer its own question: -What is the least number of attempts you need to make, to ensure it will light up the torch? - There is no proof that you can't do it in 6 or less, just that it works for 7.
reply
Add a review, comment
Other channel videos















