Open In App

Puzzle – Flashlight and 8 Batteries

Last Updated : 18 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

You have 8 batteries, 4 are dead and 4 have charges, 2 charged batteries are required to use a flashlight. How many battery pairings must you test for the flashlight to turn on?

Puzzle – Batteries

Solution: In any puzzle of this kind we first need to Let’s analyze the statement

Flashlight requires Two charged Batteries to light up. There are a total of 8 batteries: 4 charged and 4 uncharged. We don’t know which batteries are charged. The goal is to make the least number of attempts to light up the Flashlight

Now, to reach the goal the approach requires two important things:

  • Considering all the worst-case scenarios which guarantee that the flashlight will light up in the end
  • Optimize the result such that it will reduce the number of attempts

The key to the optimal solution is in the grouping in approach one you have full groups of two batteries each and in the second approach, you have two groups of four batteries each you see everything in even numbers did you think of odd number groupings?

To get the optimal solution we divide the batteries into 3 groups, 1st and 2nd groups contain 3 batteries each and the 3rd group contains the remaining two batteries.

Puzzle – Batteries

you have these three groups in the first group make three attempts with three combinations,

Three combinations of the 1st grp

  • The worst-case scenario is that none of the combinations of the lights of the charge can happen only if the group has either two discharged batteries or all three discharged batteries but you must consider that it has two discharged batteries so that the other discharged battery can be put in another group to make further worst-case scenarios.

Wrong pairing

Number of attempts = 3

Similarly, in the second group make three attempts with three combinations

Wrong pairing

Number of attempts = 6

Considering all previous worst cases this pair of two batteries must have both charged batteries which will ensure that it lights up the Flashlight

 

Number of attempts = 7

So by making the groups with three and two batteries we can ensure that it will take only seven attempts to guarantee that it lights up the Flashlight.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads