## Let’s say that you have 25 horses, and you want to pick the fastest 3 horses out of those 25. In each race, only 5 horses can run at the same time because there are only 5 tracks. What is the minimum number of races required to find the 3 fastest horses without using a stopwatch?

This question is an interesting one. Let’s start by asking ourselves, what are our limitations? Well, we don’t have a stopwatch so we can’t time the horses. That means that we can’t compare the race times of each horse – otherwise we could simply have 5 races of 5 horse each and pick out the 3 fastest times to get the 3 fastest horses. Remember that we can only race 5 horses in each race (otherwise we could just have one race with 25 horses, pick the 3 fastest, and we would be done!).

## Draw out a table

In problems like this, it helps tremendously to create some sort of visual aid that you can refer to. With that in mind, we have created this table where each entry represents a different horse.

```X1   X2   X3   X4   X5
X6   X7   X8   X9   X10
X11 X12 X13 X14 X15
X16 X17 X18 X19 X20
X21 X22 X23 X24 X25
```

Let’s say that we have 5 races of 5 horses each, so each row in the table above represents a race. So, “X1 X2 X3 X4 X5 ” represents a race, and “X6 X7 X8 X9 X10 ” represents another race, etc. In each row, the fastest horses are listed in descending order, from the fastest (extreme left) to the slowest (extreme right). The fastest horses in each race are the ones on the left – so in the first race X1 was the fastest and X5 was the slowest. In the second race X6 was the fastest, X7 was the second fastest and so on.

## Only 5 horses each race

So, now we ask ourselves: what do we know after these 5 races? Well, we do have the 5 five fastest horses from each race (X1, X6, X11, X16, and X21). But, does that mean we have the 5 fastest horses? Think about that for a second. Well, actually it does not mean that we have the 5 fastest horses. Because, what if the 5 fastest horses just happened to be in the first race – so X1 X2 X3 X4 X5 are the fastest horses. X1, X6, X11, X16, and X21 are all the fastest horses in their individual groups, but there could be one group that just happened to have all of the fastest horses. Remember we haven’t compared all the horses to each other since we can only run 5 horses in a race, so that is still a possibility. This is very important to understand in this problem.

## Work through a process of elimination

Well, now that we’ve had 5 different races, we can eliminate the slowest 2 horses in each group since those horses are definitely not in the top 3. This would leave these horses:

```X1   X2   X3
X6   X7   X8
X11 X12 X13
X16 X17 X18
X21 X22 X23
```

We also know the 5 fastest horses from each group – but it’s important to remember that the 5 group leaders are not necessarily the 5 fastest horses. So what can we do with that information?
Well, we can race those 5 horses against each other (X1, X6, X11, X16, and X21) and that would be the 6th race. Let’s say that the 3 fastest in that group are X1, X6, and X11 – automatically we can eliminate X16 and X21 since those 2 are definitely not in the top 3.

What other horses can we eliminate after this 6th race? Well, we can automatically eliminate all the horses that X16 and X21 competed against in the preliminary races – since X16 and X21 are not in the top 3 then we also know that any horse that’s slower than those 2 is definitely not in the top 3 either. This means we can eliminate X17 X18 X22 and X23 along with X16 and X21.

Now, we also know that X1 is the fastest horse in the group since he was the fastest horse out of the 5 group leaders. So, we don’t need to race X1 anymore. Are there any other horses that we can eliminate from further races? Well, actually there are. Think about it – if X6 and X11 are the 2nd and 3rd fastest in the group leaders, then we should be able to eliminate X8 since X6 raced against him and he was in 3rd place in that race. X7 could only possibly be the 3rd fastest, and since X8 is slower than X7, we can safely eliminate X8. We can also eliminate X12 and X13 since X11 was the 3rd fastest in the group leaders, and X12 and X13 were slower than X11.
So, all together we can eliminate these horses after the 6th race: X17 X18 X22 X23 X16 X21, X12, X13, X8 and X1. This leaves us with the following horses to determine the 2nd and 3rd fastest horses:

```X2   X3
X6   X7
X11
```

## What is the solution?

This means we only have 5 horses left! Now we race those horses one more time – in the seventh (7th) race – and we can take out the top 2 horses and that would mean we have the 2nd and 3rd place horses! So, we have found our answer! It takes 7 races to find the top 3 horses in this problem.

Subscribe to our newsletter for more free interview questions.

• rajesh verma

I did not get u how u found 8..please share solution

• Matthew Woods

All you know from race 1 is that the winner is the fastest. You would need the remaining horses to run again to see if they are faster than the field. You would then need to have the winner from each race race each other. Each cycle you eliminate 4 horses. This needs to continue until you have a field of five horses and you can visually see who are the 3 fastest. The correct answer is 66 races.

• Tyler

Lisa,

C2 should not be in Race 7. If C1 is the third fastest horse in Race 6, then C2 cannot be in the top 3. Therefore, A2,A3,B1,B2,C1 are in Race 7 with your fastest 2 rounding out the top 3 with A1.

• Hani

You guys must be in elementary school
You need 12 races
After 5 races you end up with 15 horses
After 3 more races you end up with 9 horses
After 2 more races you end up with 6 horses
After 2 more races you end up with the winners
Total from above is 12 races in total

• Jjletho

Lisa you are right. 8 is the minimum

• Lisa Kiker

Okay, this is driving me crazy. I see that someone said the answer is 7. I can’t get below 8. What am I doing wrong?

Races 1-5: separate the 25 horses into groups of 5
Race 6: race the fastest in each group (call them A1, B1, C1, D1, E1)

That eliminates the bottom two groups completely, and identifies the fastest horse. It also eliminates the third horse in the other two groups. So now there are 6 horses left for the remaining two spots (A2, A3, B1, B2, C1, C2)

Race 7: all except A3. If B1 or B2 win, the answer is known (A1 plus the top two from race 7). But if A2 wins, then we know the top two but A3 could still be the third fastest.

Race 8: A3, B1, C1

Am I missing something?

• 朱秉

The answer is wrong!
If you think all those horses are boxes carrying different integer value.
You want to sort those boxes to find those boxes with largest 3 numbers.
Original assumption is that the X2 > X3 (after the first round) and X6 > X11 (after the first try of 2nd round).
Nevertheless, during the 2nd try of 2nd round, it can happen that X3 > X2 or X11 > X6.
The inference fails all the relation set in the first round.
So, actually, we have to find those 2 max out of the last 5 based on these relations:
X2 > X3, X6>X7 and X6>X11 !!

• Manu Agrawal

Yeah mine too got reduced to 27, Sorry I miscalculated 26 it at first. This is how I did it.
100 horses-> 20 races, 20 winners.
Now we deal with winners only at first.
20 winners-> 4 races, 4 winners.
4 winners -> 1 race.
Now from the last race, we have 1,2 and 3(say x,y nd z resp). Also the 2 runner ups of the first and second races that x participated re potential candidates for 2nd and 3rd and also the 1st runner up in races that 2 participated is potential for 3rd pos. So we are left with y,z,(4 from x runner ups) and 2 from y’s runner ups.
So total 8 horses->2 races.
Total- 27.

• Rachit Jain

How did you come up with a solution of 26?
I boiled down to 27 but am unable to figure out a way to get to 26.!

• Manu Agrawal

What would be the answer if horses were 100? I came up with 26 as best solution. Any better?

• SHAIK MOHAMMAD SUHAIL

there is no mentioning of bestcase!

• Shubham Kumar

hope u get placed with this logic

• aaa

your solution is not correct. what if second fastest horse if first race is the second fastest horse
there are chances that top three horses are in same group. read question’s explaination again.
thank you

• Shashank Kumar

yes, but X4 and X5 are not in the fastest 3, so anyways they are going to be eliminated, the elimination order is not important

• kumar

The correct Solution is From 6th Run we can find fastest horse at the position 1st,2nd,3rd.

Logic Clarification :

Step 1 : Break 5 Group with 5 Horses from 25 Horses.

First Run : Choose Fastest from Group 1

Second Run : Choose Fastest from Group 2

Third Run :Choose Fastest from Group 3

Forth Run : Choose Fastest from Group 4

Fifth Run : Choose Fastest from Group 5

Step 2 : Create group for all fasted Horse.

Sixth Run : Three fasted Horse , based of position taken in Run like 1st.2nd,3rd.

Note : No need to check another horses, because all fasted horses are from individual Group.

Looks you Valuable suggestion if required.

Thanks

• Tyler Azevedo

6 is correct but your method is wrong. Since you only take the top from each of the first 5 races, it doesn’t account for the second place winner in any of the first 5 races potentially being the second or third fastest horse overall.

• Tyler Azevedo

The question is asking for the best case scenario: minimum number of races.

The best case would be if the data is sorted already, in other words, the fastest horse is horse #1 and the slowest horse is horse #25.

Here are the races:

Race 1:
H1 – H5

From there you know the three fastest horses, but you still have to compare to the field. What you really need to compare is horse #3 against the field. The remaining races would be:

Race 2:
H3, H6-H9

Race 3:
H3, H10-13

Race 4:
H3, H14-17

Race 5:
H3, H18-21

Race 6:
H3, H22-25

So that is 6 races.

Of course if the data isn’t sorted, then the original method that got 7 is the best.

• Tyler Azevedo

You are on the right track.

• Denzel Bacarra

Not a good answer. How about X2 and X3 supposing that they are much faster than X6 and X11 or X7 and X8 faster than X2 and X3?

• Siddharth Jain

What if we get the top horse from each race and then we get 5 finalist and race in between to get the top 3 horse. and that is 6 races 😀

• Ali

Its the same thing even your and is 8 races 😀

• Rahul Mittal

answer is 3 races:

5 groups of 5: A, B, C, D, E

Race the winners of each group against each other: A1, B1, C1, D1, E1

Assuming they finish in that order (A1, B1, C1, D1, E1) then the top 3 horses can be:

A1, A2, A3
A1, A2, B1
A1, B1, B2
A1, B1, C1

A1 is known as the fastest…so race A2, A3, B1, B2, C1 in a 3rd race and the top 2 are 2nd and 3rd.

• kEyz

You are right that X4 and X5 could be faster than X6 but that is not relevant. No matter what, X4 NOR X5 will be the fastest THREE horses because they will always be behind X1 – X3.

And in your case, you will eventually find out that X2 and X3 are faster than X6 from the last race, which allows us to eliminate X6.

• Naseer

this is wrong logic

let say

first group
X1 finished 3 min
X2=4min
X3=5min
X4=6min
X5=7min

second group
X6=8mi
X7=9min
X8=10 min
X9=11min
X10=12 min

based on your not, if eliminating first group slowest 2 then answer is wrong. am i right? because X4 and X5 are faster than second group.