Minimum Batteries-Puzzle for Interview rounds

Question :

There are 8 batteries, but only 4 of them work. A flashlight needs only 2 working batteries. To guarantee that the flashlight is turned on, what is the minimum number of battery pairs you need to test?

Solution :

To solve this problem, the first step involves naming the batteries, for instance, A, B, C, D, E, F, G, and H. In this problem, you can’t compare 2 items directly. If a combination of two batteries fail to turn the light on, it means either one or both the batteries aren’t working. The batteries are put test consecutively in the order AB, BC, and AC. At most, one of the three batteries between A, B, And C is working, only if none of the pairs work. This also implies that at least three batteries between D, E, F, G, and H must be functional. DE combination is tried next. If they don’t work, at least 2 out of F, G, and H must work. Similarly, try the combinations FG, GH, and FH to positively asset which batteries really work.

Thanks for Reading

Placewit grows the best engineers by providing an interactive classroom experience and by helping them develop their skills and get placed in amazing companies.

Learn more at Placewit. Follow us on Instagram and Facebook for daily learning.




Upskilling students for tech placements!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Quick Start to OceanBase: High-Availability Model and Disaster Recovery Solution

How to Code Complex Applications: Core Java Technology and Architecture

RoadMap to Web development

Quick Guide to Seamlessly Connect gRPC with Dubbo-go

KubeCon 2019: Alibaba Cloud Hands-on Workshop Highlights

Building SaaS Integrations

Rethink Full Human

The Cluster:improve the stability of the reporting system

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Upskilling students for tech placements!

More from Medium

Bee Travel Puzzle

1570. Dot Product of Two Sparse Vectors

Meta / Amazon / Google / Microsoft Interview Question: Wildcard Matching Solution | LeetCode-44…

LeetCode 146. LRU Cache