you have 25 horses and 5 horse can race in a group. how many minimum races you have to do to find the top 3 horses in group.
step 1: divide 5 horses in 5 groups and race then (5 races).
Group A, Group B, Group C, Group D, Group E
step 2: take top from each race and race them ex. A1, B1, C1, D1, E1 (1 race)
step 3: Now suppose A1 top the race, so take second person from A's group and rest of person from step 2 ex. A2, B1, C1, D1, E1 (1 race ). Who ever will top the race will be top second
Step 4: Now Suppose B1 top the race, so take second person from B's group and rest of person from step 3 ex. A2, B2, C1, D1, E1 (1 race ). Who ever will top the race will be top third
Congrats you got top 3 in just 5+1+1+1 = 8 races.
It can be more optimize and solution is 7 race.
After 6th race (step 2)
Discard the group C and D because we want only top 3.
Discard C2 onward (C2, C3 ..) because they will never come in top 3
Now Discard B3 onwards because B1 can be second and B2 can be third max.
So A1 is top 1
and you have qualified horses for second and third position is: A2, A3, B1, B2, C1
race then and find the top 2 and top 3.
Total races 5+1+1 = 7