The Wayback Machine - https://web.archive.org/web/20240726182019/https://www.geeksforgeeks.org/puzzle-9-find-the-fastest-3-horses/
Open In App

Puzzle 9 | (Find the fastest 3 horses)

Last Updated : 25 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report

There are 25 horses among which you need to find out the fastest 3 horses. You can conduct a race among at most 5 to find out their relative speed. At no point, you can find out the actual speed of the horse in a race. Find out the minimum no. of races which are required to get the top 3 horses.

Find the fastest 3 horses

Solution:

First, we group the horses into groups of 5 and race each group on the race course. This gives us 5 races (see image below). 

 

Find the fastest 3 horses

  • In the image, each row represents one race of 5 horses. For convenience, let us name the horses using the row and column index. Therefore, the first race(row 1) was contested between the horses R1C1, R1C2, R1C3, R1C4 and R1C5. The second race (row 2) was contested between the horses R2C1, R2C2 and so on. Let us assume that the fifth member of each row won the race (R1C5 won the first race, R2C5 won the second race and so on), the fourth member of each row came second (R1C4 came second in the first race, R2C4 came second in the second race and so on) and the third member of each group came third (R1C3 came third in the first race, R2C3 came third in the second race and so on). 

     

Find the fastest 3 horses

  • Next, we race the 5 level 1 winners (R1C5, R2C5, R3C5, R4C5 and R5C5). Let’s say R1C5 wins this race, R2C5 comes second and R3C5 comes third. 

     

Find the fastest 3 horses

  • The winner of this race (R1C5) is the fastest horse of the entire group. Now, the horse which is second in the entire group can either be R2C5 or R1C4. The horse which is third in the entire group can either be R3C5, R2C4 or R1C3. Therefore, we race these 5 horses. 

     

Find the fastest 3 horses

Therefore, the horse R1C5 is the fastest horse. The horses which come first and second in the last race are the horses which are second and third in the entire group respectively. in this way, the minimum number of races required to determine the first, second and third horses in the entire group is 7. 
 

Alternate Explanation: 

Make group of 5 horses and run 5 races. Suppose five groups are [a, b, c, d, e] and next alphabet is its individual rank in this group(of 5 horses).for eg. d3 means horse in group d and has rank 3rd in his group. [ 5 RACES DONE ] 
a1 b1 c1 d1 e1 
a2 b2 c2 d2 e2 
a3 b3 c3 d3 e3 
a4 b4 c4 d4 e4 
a5 b5 c5 d5 e5 

Now make a race of (a1,b1,c1,d1,e1).[RACE 6 DONE] suppose result is a1>b1>c1>d1>e1 
which implies a1 must be FIRST. 
b1 and c1 MAY BE(but not must be) 2nd and 3rd. 
FOR II position, horse will be either b1 or a2 
(we have to find top 3 horse therefore we choose horses b1,b2,a2,a3,c1 do racing among them [RACE 7 DONE]. 
The only possibilities are : 
c1 may be third 
b1 may be second or third 
b2 may be third 
a2 may be second or third 
a3 may be third 
The final result will give ANSWER. suppose result is a2>a3>b1>c1>b2 
then answer is a1,a2,a3,b1,c1. 
HENCE ANSWER is 7 RACES 

Please note that the 7 races work for the case also when all top 3 horses are same group or any top two horses are in same group. The group which has top 3 horses would always have winner in 6th race. In 7th race, we consider 2nd and 3rd horses of the group whose horse is overall winner. We also consider 2nd horse of the group whose horse came 2nd in 6th race. 

 


Previous Article
Next Article

Similar Reads

Fastest Horse Query in a Race
Given ‘N’ horses running in ‘N’ different lanes numbered from 1 to ‘N’. You are given an array “FINISHTIME” containing ‘N’ integers where “FINISHTIME[i]” represents the time taken by the ith horse to complete the race. Also given are ‘Q’ queries, each containing two integers each, ‘L’ and ‘R’. For each query, return the time taken by the fastest ho
8 min read
Puzzle | Man fell in well Puzzle
A man fell in a 50m deep well. He climbs 4 meters up and slips 3 meters down in one day. How many days would it take for him to come out of the well? Answer: 47days Explanation: On the first day, the man climbs 4 meters up and slips 3 meters down, therefore he only climbs 1 meter up totally.On the second day, again he climbs 1 meter up, so the tota
1 min read
Puzzle - A LITTLE TRAIN PUZZLE
A nonstop express going sixty miles an hour starts from Bustletown for Ironchester, and another nonstop express going forty miles an hour starts at the same time from Ironchester for Bustletown. How far apart are they exactly an hour before they meet?Because the two stations cannot be found on any map or gazetteer, we cannot state the distance betw
1 min read
Puzzle | The Einstein's Puzzle
Einstein's puzzle is a famous logic puzzle that was supposedly created by Albert Einstein as a boy. The puzzle goes as follows:There are five houses in a row, each with a different color. In each house lives a person of a different nationality. The five owners drink a certain type of beverage, smoke a certain brand of cigar, and keep a certain pet.
4 min read
Puzzle 15 | (Camel and Banana Puzzle)
A person has 3000 bananas and a camel. The person wants to transport the maximum number of bananas to a destination which is 1000 KMs away, using only the camel as a mode of transportation. The camel cannot carry more than 1000 bananas at a time and eats a banana every km it travels. What is the maximum number of bananas that can be transferred to
4 min read
Puzzle 24 | (10 Coins Puzzle)
You are blindfolded and 10 coins are placed in front of you on the table. You are allowed to touch the coins but can’t tell which way up they are by feel. You are told that there are 5 coins head up, and 5 coins tails up but not which ones are which. Can you make two piles of coins each with the same number of heads up? You can flip the coins any n
1 min read
Puzzle 27 | (Hourglasses Puzzle)
Puzzle: Given two hourglass of 4 minutes and 7 minutes, the task is to measure 9 minutes. Solution: At 0 minutes: Start both hourglasses at the same time. At 4 minutes: 4 minutes hourglass runs out and flip it. 7 minutes hourglass is left with 3 minutes. At 7 minutes: 4 minutes hourglass is left with 1 minute. 7 minutes hourglass runs out and flip
1 min read
Puzzle 28 | (Newspaper Puzzle)
Question: A newspaper made of 16 large sheets of paper folded in half. The newspaper has 64 pages altogether. The first sheet contains pages 1, 2, 63, 64. If we pick up a sheet containing page number 45. What are the other pages that this sheet contains? Answer: On the back of 45, it is 46. The pages are such that for each page p, 65-p will be also
1 min read
Puzzle 31 | (Minimum cut Puzzle)
Puzzle: You have got someone working for you for five days and a gold bar to pay him. You must give them a piece of gold at the end of every day. What are the fewest number of cuts to the bar of gold that will allow you to pay him 1/5th each day? Answer: 2 cuts. Solution: Explanation 1: After two cut there are three pieces of [1 unit and two 2 unit
2 min read
Puzzle 33 | ( Rs 500 Note Puzzle )
A Lady (L) bought an item of Rs 100 from the Shopkeeper (C). She paid him through a 500 Rs Note. Realizing that he did not have change, the shopkeeper C got change for that note from another shopkeeper (S) and paid Rs 400 to the Lady. After a few days, S realized that the note is fake, And this railed at C and took 500 Rs back from him. So in this
1 min read
three90RightbarBannerImg