Torch and Bridge | Puzzle

Author: neptune | 11th-Dec-2022
#Interview

Puzzle: There are 4 persons (A, B, C, and D) They want to cross a bridge at night.

1. A takes 1 minute to cross the bridge.

2. B takes 2 minutes to cross the bridge.

3. C takes 5 minutes to cross the bridge.

4. D takes 8 minutes to cross the bridge.

There is only one torch with them and the bridge cannot be crossed without the torch. There cannot be more than two persons on the bridge at any time, and when two people cross the bridge together, they must move at the slower person’s pace.

Is it possible to cross the bridge in 15 minutes?


Solution:
Let's see how they cross the bridge in 15 minutes.

Step 1: A and B cross the bridge. A comes back. 

A+B = 1+2 = 3 minutes

Now B is on the other side.

A, C, D   ————————  B


Step 2: C and D cross the bridge. B comes back. 

C+ D = 8 + 2 = 10 minutes

Now C and D are on the other side.

A, B     ————————  C, D


Step 3: A and B cross the bridge. Noone comes back. 

A+B = 2 minutes

All are on the other side.

            ————————  A, B, C, D


Total time spent: 3 + 10 + 2 = 15 minutes.


Trick to apply:

Trick is persons with the fastest speed only should come back (only if there is a need to come back as here we need to bring back the torch).

Let me know in comment if you have any questions.
 




Related Blogs
Where you applied OOPs in Automation Testing?
Author: neptune | 28th-Aug-2023
#Interview #Java
You may face this question Where you have applied OOPs concept in Automation Framework? in almost all the Selenium Interviews. Let's learn OOP’s concept in Java before going further...

Top 50+ Selenium Interviews Questions 2023 based on Years of Experience
Author: neptune | 02nd-Apr-2023
#Selenium #Testing #Interview
Every interview difficulty is based on how many years of experience you have in that field. For the Selenium Automation Tester I have divided the question on the number of years of experience...

Mostly asked Python Interview Questions - 2023.
Author: neptune | 30th-May-2023
#Python #Interview
Python interview questions for freshers. These questions asked in 2022 Python interviews...

Core Python Syllabus for Interviews
Author: neptune | 26th-Jul-2023
#Python #Interview
STRING MANIPULATION : Introduction to Python String, Accessing Individual Elements, String Operators, String Slices, String Functions and Methods...

Top 10 Selenium Interview Questions with answers (2021).
Author: neptune | 02nd-Apr-2023
#Selenium #Interview
In this article I will cover top 10 Selenium interview questions...

30+ SQL Interview Questions
Author: neptune | 05th-Jan-2023
#Interview #SQL
Data Definition Language (DDL) – It allows end-users to CREATE, ALTER, and DELETE database objects...

20 TestNG Interview Questions
Author: neptune | 17th-Dec-2022
#Selenium #Interview
There is always more than one test or method in the class. If we do not prioritize these tests or methods, then the methods are selected alphabetically and executed while execution...

Top 10 Selenium Interview Questions.
Author: neptune | 02nd-Apr-2023
#Selenium #Interview
Locator is a command that tells Selenium IDE which GUI elements (like Text Box, Buttons, Check Boxes etc) we are going to use or perform some automation task...

Black Mirror Season 6: A Glimpse into the Future of Technology and Society
Author: neptune | 27th-Apr-2023
#Interview
Black Mirror Season 6, starring Salma Hayek and Aaron Paul, promises more violence and thought-provoking explorations of technology and society...

The Key to QA Success: Understanding How Important Grooming Is?
Author: neptune | 19th-Sep-2023
#Testing #Interview
We will delve into the importance of grooming & ceremony for QA testers, key points to highlight their significance...

Top 20+ Appium Interview Questions and Answers (2023)
Author: neptune | 30th-May-2023
#Interview
This article provides a comprehensive list of 20 common interview questions on Appium mobile automation, covering various topics and providing solutions for each question...

Skills Required for Full-Stack Developer at IBM Onsite, CA
Author: neptune | 25th-Feb-2024
#Interview #Jobs
The company's commitment to pushing the boundaries of what is possible necessitates a team of skilled professionals...

View More