Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Problem Statement
3.
Solution
4.
Frequently asked questions
4.1.
What are interview puzzles?
4.2.
How to answer puzzle interview questions?
4.3.
What are some types of interview puzzles?
5.
Conclusion
Last Updated: Mar 27, 2024

Bee Travel

Author Rajat Agrawal
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @
Interview Puzzles

Introduction

Puzzles are good exercise for the brain. They help in enhancing the cognitive abilities of the brain helping with Problem Solving and related skills. There are numerous types of puzzles; each one having a logic inherent to itself which helps in cracking it. A good puzzle well is actually like a good mystery that we may have read about or watched on TV. It has the finest of hints which help in reaching its solution.

The following article discusses one such puzzle so let's get right to it.

Problem Statement

Two trains simultaneously enter a 200-miles long tunnel, traveling at 100 mph in opposite directions.

As soon as they enter the tunnel, a 1000 mph supersonic bee takes off from one train and flies for the other one.

As soon as it reaches the other, it turns around and returns to the first, traveling back and forth between the trains until they meet in the center of the tunnel in a fiery explosion.

How far did the bee travel?

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Solution

Given,

Speed of  both trains = 100 mph
Length of tunnel = 200 miles
Speed of bee = 1000 mph

From the problem statement, it is clear that both the trains will collide,

time of fly of bee = (total distance traveled by trains) / (total speed of both trains)
Let t = time of fly of bee, 
t = (200 miles) / (100+100 mph) = 1hr.

 

The bee can fly as long as the train doesn't collide, i.e., 1hr.

 

So, the distance traveled by the bee is given by:-

distance traveled by bee = (speed of bee)*(time of fly of bee)
Let d = distance traveled by bee, 
d = (1000 mph)*(1hr)
d = 1000 miles.

 

So the bee will travel 1000 miles before the collision of trains.

Frequently asked questions

What are interview puzzles?

Interview puzzles are some critical thinking problems or brain teasers.

How to answer puzzle interview questions?

We need to first think about the problem, then ask for clarification, use whatever resources we have, explain our reasoning, and provide the solution.

What are some types of interview puzzles?

Riddles and questions, finding amounts, and number tricks.

Conclusion

In this article, we have extensively discussed the bee travel puzzle and solved the problem. 

Recommended Readings:


Do check out The Interview guide for Product Based Companies as well as some of the Popular Interview Problems from Top companies like Amazon, Adobe, Google, etc. on Coding Ninjas Studio.

Also check out some of the Guided Paths on topics such as Data Structure and Algorithms, Competitive Programming, Operating Systems, Computer Networks, DBMS, System Design, etc. as well as some Contests, Test Series, Interview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Do upvote our blog to help other ninjas grow.

Happy Coding!

Previous article
Make a Statement
Next article
Prisoners and Poison
Live masterclass