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.
In how many races we can determine the fastest horse if the above constraints are followed?
4.2.
In the 7th race, why were only five horses considered?
4.3.
Why should I practice these types of puzzles?
4.4.
Do MNCs ask puzzles in the interview of IT companies?
4.5.
From where can I practice more such puzzles?
5.
Conclusion
Last Updated: Mar 27, 2024

Fastest Horses

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

Introduction

Puzzles are critical thinking problems that test a person's lateral thinking and problem-solving skills, similar to brain teasers. These types of puzzle questions are commonly used by interviewers to assess a potential employee's ability to solve complex problems using strategies and higher-order thinking to determine their fit for the company.

In this article, we will solve the puzzle ‘fastest horses’.

Problem Statement 

There are 25 horses, among which you need to find the top 3 fastest horses. You can conduct a race among at most 5 to determine their relative speed. Find out the minimum number of races that are required to determine the top 3 horses. 

Note: You cannot find out the actual speed of the horse in a race at any point. 

Hints

  1. Find out the fastest horse and the group to which the fastest horse belongs. The group may contain 2nd and 3rd fastest horses.
     
  2. Try to minimize races. Can you do it in 8 races? Then further try to lower the number.
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

First, make 5 groups, each group containing 5 horses, so a total of 25. After conducting 5 races, arrange the horses according to their ranks in a row. See the table below; the horses of each group are arranged according to their rank in a row.

Illustration Image


Horses in column 5 are the fastest and in column 1 are the slowest; also in each row, horses are arranged according to their speed

Now conduct a race among column 5 horses. The horse that came first will be the fastest horse, and the horses which came second and third can be possible answers for 2nd and 3rd place. (Moreover shuffle the rows arrange, according to the horses that came 1st 2nd and 3rd, the row from which the fastest horse belongs will be on top, and the same is true for second and third). 

Illustration Image


Till now, there have been 6 races. And we have determined the fastest one. Now, which can be considered for the 2nd and 3rd positions?

Illustration Image


For the second position,

  1. The horse which came second in the 6th race can be a possible answer and,
  2. The horse which came second from the group to which fastest horse(at position 1, the horse at row[1]col[5]) belongs. 

These two horses will be just slower than the horse which came first and faster than all other horses. (Think over it)

Similarly for position 3, horses at position row[3]col[5], row[2]col[4] and row[1]col[3] are possibilities. 

  1. The horse may be the one that came third in the 6th race.
  2. The one which came 3rd in the group to which the fastest horse belongs.
  3.  Also, a horse that is just slower than horses that are possibilities for 2nd position can be a solution, its horse row[2]col[4]

(Just think for a while).

Now we have 5 horses, and among these only, 2nd and 3rd fastest horses will be present. Conduct a race among them the horse which came first this time, will be second fastest horse and the one which came 2nd will be the third fastest.

So a total of 7 races are required.

Check out this problem - 8 Queens Problem

Frequently Asked Questions

In how many races we can determine the fastest horse if the above constraints are followed?

6 races, the first 5 to determine the fastest from each group. Then, a 6th one to know the fastest.

In the 7th race, why were only five horses considered?

It is because they are arranged in increasing order of their speed, and all other horses would be slower than them.

Why should I practice these types of puzzles?

These types of puzzles help you to improve your logical and problem-solving skills. Moreover, they are also asked in company interviews.

Do MNCs ask puzzles in the interview of IT companies?

Many tech giants like Google, Microsoft, etc., ask the puzzles in the interview process as they want to check your logical thinking.

From where can I practice more such puzzles?

You can refer to the key takeaways section for links to many puzzle sections.

Conclusion

In this article, we have extensively discussed a famous puzzle of the fastest horses. We hope that this blog has helped to understand the puzzle well. 

Recommended Readings:


Recommended Mathematical Puzzles:


Recommended Pattern-Based Puzzles:


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 Learning!

Previous article
Gates of Heaven
Next article
Train Station
Live masterclass