Solving A Classic Google Interview Logic Puzzle

Поділитися
Вставка
  • Опубліковано 8 чер 2024
  • There are 25 mechanical horses and a single racetrack. Each horse completes the track in a pre-programmed time, and the horses all have different finishing times, unknown to you. You can race 5 horses at a time. After a race is over, you get a printout with the order the horses finished, but not the finishing times of the horses. What is the minimum number of races you need to identify the fastest 3 horses?
    I was suggested this puzzle via email by Terry Stickels. This is also a popular interview question at tech companies like Google. See a list of all sources in my blog post for this video:
    wp.me/p6aMk-58P
    Subscribe: ua-cam.com/users/MindYour...
    Send me suggestions by email (address in video). I consider all ideas though can't always reply!
    Why are there comments before the video is published? Get early access and support the channel on Patreon
    / mindyourdecisions
    If you buy from the links below I may receive a commission for sales. This has no effect on the price for you.
    Show your support! Get a mug, a t-shirt, and more at Teespring, the official site for Mind Your Decisions merchandise:
    teespring.com/stores/mind-you...
    My Books
    Mind Your Decisions: Five Book Compilation
    amzn.to/2pbJ4wR
    A collection of 5 books:
    "The Joy of Game Theory" rated 4.1/5 stars on 44 reviews
    amzn.to/1uQvA20
    "The Irrationality Illusion: How To Make Smart Decisions And Overcome Bias" rated 3.5/5 stars on 4 reviews
    amzn.to/1o3FaAg
    "40 Paradoxes in Logic, Probability, and Game Theory" rated 4.4/5 stars on 13 reviews
    amzn.to/1LOCI4U
    "The Best Mental Math Tricks" rated 4.7/5 stars on 8 reviews
    amzn.to/18maAdo
    "Multiply Numbers By Drawing Lines" rated 4.3/5 stars on 6 reviews
    amzn.to/XRm7M4
    Mind Your Puzzles: Collection Of Volumes 1 To 3
    amzn.to/2mMdrJr
    A collection of 3 books:
    "Math Puzzles Volume 1" rated 4.4/5 stars on 13 reviews
    amzn.to/1GhUUSH
    "Math Puzzles Volume 2" rated 4.5/5 stars on 6 reviews
    amzn.to/1NKbyCs
    "Math Puzzles Volume 3" rated 4.1/5 stars on 7 reviews
    amzn.to/1NKbGlp
    Connect with me
    My Blog: mindyourdecisions.com/blog/
    Twitter: / preshtalwalkar
    Newsletter (sent only for big news, like a new book release): eepurl.com/KvS0r
    2017 Shorty Awards Nominee. Mind Your Decisions was nominated in the STEM category (Science, Technology, Engineering, and Math) along with eventual winner Bill Nye; finalists Adam Savage, Dr. Sandra Lee, Simone Giertz, Tim Peake, Unbox Therapy; and other nominees Elon Musk, Gizmoslip, Hope Jahren, Life Noggin, and Nerdwriter.
  • Наука та технологія

КОМЕНТАРІ • 24 тис.

  • @MindYourDecisions
    @MindYourDecisions  7 місяців тому +54

    7 million views! Thank you! Here's a Microsoft interview puzzle I think you will enjoy. A cat is hiding in one of five boxes that are lined up in a row. The boxes are numbered 1 to 5. Each night the cat hides in an adjacent box, exactly one number away. Each morning you can open a single box to try to find the cat. Can you win this game of hide and seek? What is your strategy to find the cat? What if there are n boxes? Watch the video for the solution! ua-cam.com/video/yZyx9gHhRXM/v-deo.html

    • @sandrathiel4475
      @sandrathiel4475 7 місяців тому +1

      I know this is a little bit late but i got a different result and i want to know if it is right.
      My result was 6,because that in the same race that we used to discover the first fastest horse we could use to discover the second and third fastest horse.
      Sorry if it is hard to understand, it's because i'm not english.

    • @MrJelle18
      @MrJelle18 5 місяців тому

      ​@@sandrathiel4475Sorry, no, you can't put more than five horses in one race.

    • @LiquidGhost117
      @LiquidGhost117 5 місяців тому +3

      You provided 7 million people with an inaccurate method.

    • @sandrathiel4475
      @sandrathiel4475 5 місяців тому

      @@MrJelle18 I was saying that,in the race that we discovered the fastest one,we could say that the second and third place would be the second and third fastest horses.

    • @brunobanani6198
      @brunobanani6198 5 місяців тому +1

      ​@@sandrathiel4475 How do you know the 3 fastest aren't in A.

  • @arthuredens
    @arthuredens 3 роки тому +19773

    If I race 5 horses at a time there's no way I can beat any of them, horses are fast

    • @flatebo1
      @flatebo1 3 роки тому +536

      Depends on the race. Run them through an Army obstacle course. I'm guessing they'll get hung up on the wall climbing, rope swinging and belly crawl parts.
      It also depends on the length of the race. Native American runners could outrun horses in an endurance race. People are willing to keep going when animals would quit. So, if you're in shape for a marathon, you'll probably win.

    • @seraphina985
      @seraphina985 3 роки тому +233

      @@flatebo1 Humans have an innate advantage in an endurance race vs most animals our species evolved to hunt critters by running them to exhaustion, that is to say we are naturally built for persistence hunting.

    • @markntexas8265
      @markntexas8265 3 роки тому +51

      Truer words were never spoken

    • @solar0wind
      @solar0wind 3 роки тому +36

      @@flatebo1 If the race is in high temperatures, then humans have an advantage. In colder temperatures the advantage is slimmer or maybe non existent.

    • @waleedahmad4230
      @waleedahmad4230 3 роки тому +46

      @@seraphina985 have you ever rode a horse? He is really enduring, why do you think he was used as a transport mean in the past? Even if its an endurance race he will leave a long distance with the human so he he could rest and start again, but don't worry he will not get tired before minimum 5 hours

  • @TwistedOff
    @TwistedOff 9 місяців тому +337

    Pick any 3 horses and destroy the remaining 22 horses. These three horses will be the fastest.

    • @pedrooo13
      @pedrooo13 4 місяці тому +6

      @@hayn10cause they are now 100% of the horses

    • @Golem1988
      @Golem1988 4 місяці тому +9

      I think that's how they hire people to some companies in Germany. This is why German online services suck.

    • @MrJackassss321
      @MrJackassss321 3 місяці тому +7

      Reminds me of Stalin sort :D

    • @hillarysemails1615
      @hillarysemails1615 3 місяці тому

      You score high in Machiavellianism. Congrats. ♥

    • @mydkarthikmecharena9010
      @mydkarthikmecharena9010 Місяць тому +2

      😂

  • @BradColemanisHere
    @BradColemanisHere 10 місяців тому +497

    Yeah this was great. I was having a hard time until I saw you group them in to a,b,c,d,e based off of the rank of their race. I was getting stuck on the three fastest horses being in the same race initially but the re-grouping did the trick. The visual really helps.

    • @callito9846
      @callito9846 8 місяців тому +9

      Feel you, i was stuck at a minimum of 11 races , because i wasnt regrouping and i thought id always have to let the top 3 of every race continue in case the 3 fastest horses happened to be in the same race at the start.

    • @sasquatchrosefarts
      @sasquatchrosefarts 8 місяців тому +9

      Outcomes are dependent on competition. This is a software developer question written in a bubble. And he didn't specify time , vs, outcome.
      Race six runs the winner of each group, but it takes a minimum of two races to remove all the second and third place finishers. Therefore his solution is wrong.
      It's not right.

    • @esco8778
      @esco8778 8 місяців тому +6

      I'm still a little confused. How can you order the groups based on how fast they were if you don't know their finishing times?

    • @samybean9962
      @samybean9962 8 місяців тому +2

      ​@@sasquatchrosefarts What do you mean? After race 6 you know no horse behind the third place horse can win, 1 horse behind the second place horse gets a chance for third place, 2 horses behind the first place horse get a chance for second and third place, the winner of the winners definitely is first place, leaving 5 horses to be checked so we finally know the second and third place.
      When you identify a horse is slower than a horse that turns out to be slower than a slow horse then you also learn something about the first horse even though you didn't let it race again. Horses can be identified to be slower after a later race. If I misunderstood can you explain why you consider the solution to be wrong?

    • @callito9846
      @callito9846 8 місяців тому +1

      ​@@esco8778 Well you order the groups based on the place their "winner horse" made at the "winners race". So you have the 5 races at the start, after that the 5 winner horses will race each other. After that you order the groups by the finishing order of the groups fastest horse in the "winners race".
      So if the winner horse of group C also wins the "winners race" group C will be the "fastest group".

  • @Orewastaken
    @Orewastaken 6 місяців тому +14

    When you showed step three I was confused at first, then after a few seconds my brain understood and it BLEW my mind, what a great video

  • @fostena
    @fostena 3 роки тому +2721

    You race 5 horses, sell the slowest one, and buy a watch.
    The rest is trivial

    • @ashmitneedssleep
      @ashmitneedssleep 3 роки тому +53

      As if the buyers are on standby.

    • @tamirkarniely6913
      @tamirkarniely6913 2 роки тому +45

      Best answer!

    • @alessioandreoli2145
      @alessioandreoli2145 2 роки тому +26

      Expensive watch 😂😂😂

    • @fostena
      @fostena 2 роки тому +44

      @@alessioandreoli2145 of course, a very accurate one, with stopwatch function included 🙂

    • @piyusharya1131
      @piyusharya1131 2 роки тому +4

      this is a question not a business....

  • @asterisque9252
    @asterisque9252 2 роки тому +2406

    I got 6, then realised i hadn't considered that the second fastest might be faster than another group's winner. Nice one

    • @user-sp6oy9sk9k
      @user-sp6oy9sk9k 2 роки тому +29

      Same 😐😐

    • @bradpattinian4875
      @bradpattinian4875 2 роки тому +13

      Same

    • @Anita-jg3ur
      @Anita-jg3ur 2 роки тому +33

      Same! I just thought the second and third of the sixth race would also be the fastest 🤦🏽‍♀️

    • @shadi3993
      @shadi3993 2 роки тому +91

      what i dont get is why we need 7 races :
      we must do five races for the five groups and from that we have found the 5 fastest horses of them all
      secondly we just race those five horses and the first three to finish are the fastest three horses right ?
      so that a total of 6 races !
      P.S : no where in the question does it state that you need to know their ranking aka whos fastest of the three ...

    • @ZergosaurusRex
      @ZergosaurusRex 2 роки тому +51

      @@shadi3993 But if the 3 fastest horses are in the same group your method will only identify one of them.
      Here is how you can really solve this problem with 6 races: Let 5 horses race and label the 3 fastest horses from that group A, B, C. Assume that C is the 3rd fastest horse of all 25 horses and proove that by letting C race against the remaining 20 horses with 5 more races (6 in total by now). In the unlikely case that C is indeed the 3rd fastest horse, you've identified the 3 fastest horses (A, B, C) with 6 races. This is'nt an efficent method because it requires more than 7 races on average but sometimes it can solve the problem with only 6 races.

  • @undefined7463
    @undefined7463 9 місяців тому +163

    I know I will never work at these kinds of places, but to see the thought processes in these puzzles is awesome. Training yourself to look at the same real world problem in different perspectives to solve real world engineering/ self reliance problems are invaluable. Great video

    • @Neil.Menezes
      @Neil.Menezes 8 місяців тому +5

      Never say never 😊

    • @pickleism253
      @pickleism253 5 місяців тому

      ​@@Neil.Menezesthats an oxymoron

    • @Neil.Menezes
      @Neil.Menezes 4 місяці тому +1

      @@pickleism253 fine, never say never except to say the phrase 'never say never'.

    • @McP1mpin
      @McP1mpin 4 місяці тому

      This was before logic and rational thought was deemed racist. Now states like NY are outlawing 'tests' like this in the pursuit of 'equity' and we're slowly starting to fall behind other countries like China.

  • @lluisg.8578
    @lluisg.8578 3 роки тому +3255

    In a Google's interview the better answer should always be: Google It!

  • @keymasta3260
    @keymasta3260 3 роки тому +2867

    Last season in F1 we ​​had 20 drivers and it took 17 races to identify the fastest 3 drivers

    • @you2uber530
      @you2uber530 3 роки тому +280

      This is since they are human and not mechanical horses... so their times differ from race to race.

    • @rysea9855
      @rysea9855 3 роки тому +413

      @@you2uber530 its a joke

    • @mika2666
      @mika2666 3 роки тому +90

      It took 0 races

    • @jakeelsen3285
      @jakeelsen3285 3 роки тому +65

      @@you2uber530 r/whoooosh

    • @andrewtan881
      @andrewtan881 3 роки тому +4

      Lmao

  • @frorkbrunk148
    @frorkbrunk148 11 місяців тому +127

    I got the setup exactly the same up until the 6th round, but at the seventh round I couldn't quite get the final 2 horses. I thought c2 could be faster than a2 and b2 and got confused how I'd identify the 2nd and 3rd fastest horses with such complexity. What I missed is that c2 could infact be faster than a2 and b2, but it's irrelevant as in that case there is still a1, b1 and c1 faster.
    Looking at it from the other side and eliminating all the horses that can not possibly qualify for top 3 is by far the easiest and smartest solution. I didn't come up with that.

    • @josedelarocha2455
      @josedelarocha2455 9 місяців тому +8

      Exactly, also this implies how subjective is categorizing letters a to e in the same group as 2 to 5 since there is no timer, there's no way to know if A2 is actually faster than E1 because E1 could've for example finished in 5 seconds, A1 7, but that doesn't mean A2 couldn't have finished in 4.9 making it actually slower than E1

    • @bhupendrasatpathy
      @bhupendrasatpathy 8 місяців тому +4

      I still didn’t get it. C2 could in fact be faster than a1,a2, b1, b2. So we are missing that comparison.
      But you said that is irrelevant so just want to understand what I’m missing.

    • @rediciclepop4639
      @rediciclepop4639 8 місяців тому +10

      @@bhupendrasatpathy C2 can never be in the top 3 because it is already slower than at least 3 horses: A1, B1, and C1. It is slower than C1 because it lost the race with all the Cs. It’s slower than A1 and B1 because A1 and B1 are faster than C1 since they beat it in the race of the fastest among groups.

    • @themightykabool
      @themightykabool 8 місяців тому +1

      But all of B2 3 4 5 just means they slower than B1.
      All pf A2 3 4 5 just slower than A1.
      Theres no line where B2 3 4 5 faster than A2 3 4 5 because groups are ranked by heats.
      Say A1 is 10sec.
      B1 is 9sec.
      A2 3 4 5 could all be 4sec.
      B2 3 4 5 could all be 8sec.

    • @themightykabool
      @themightykabool 8 місяців тому

      Nm
      I forgot how many horses we were going for.

  • @jamesrunco6073
    @jamesrunco6073 11 місяців тому +124

    I think the key thing to think about is that A1 is automatically in so you are now looking for the fastest combination to fill 2 spots. So if there are only 2 spots then you know that anyone in group D or E is out because there just aren't enough slots for them. Everyone in D group is slower than D1 and D1 is slower than C1. So the LONGEST possible path is A1 to C1 (because B1 will always be faster than C1. This is also why C2 is out of contention, which threw me for a second). The shortest possible path is A1 to A3. A1 is automatically in. You just need to test the viable permutations of the fastest 3 horses. So their are 4 possible outcomes that include only the 3 fastest horses. They are:
    A1, A2, A3
    A1, A2, B1
    A1, B1, C1
    A1, B1, B2
    So if you ignore the A1s since you automatically know they are automatically the fastest of the fast, you get the horses you need to test against each other being A2, A3, B1, C1, and B2. That's 5 horses which works out perfectly for a 7th race!

    • @noelmullankuzhy927
      @noelmullankuzhy927 11 місяців тому +10

      You missed one. A1, B1, A2

    • @FAMIntruder
      @FAMIntruder 9 місяців тому +6

      You have no way of knowing if any 2nd place is slower then anyone but your 1st and 1st places above your group. For all we know E2 and even E5 can be faster then A2. From racing initial groups and winners you cant derive rest of field. You do not know times so there can be massive diference between 1st and 2nd places. Dont forget that initial groups are random.
      Edit: nwm, it clicked for me after i read @frorkbrunk148 comment.

    • @slimknight_
      @slimknight_ 9 місяців тому +1

      ​@@noelmullankuzhy927 he said A1,A2,B1. In his explanation order doesnt matter, he is simply stating all sets of three possible candidates.

    • @fluffysheepfallingasleep609
      @fluffysheepfallingasleep609 8 місяців тому

      I'm so happy i managed to solve this on my own before watching the video 😄

    • @stvrob6320
      @stvrob6320 6 місяців тому

      I think Presh Telwalker's explaination is better.

  • @rossington1680
    @rossington1680 2 роки тому +2284

    Sell all but 3 of the horses….
    Those 3 will be the “fastest” horses you have. 😎

    • @epaminondas8949
      @epaminondas8949 2 роки тому +149

      0 races needed.
      Perfect score. 💯

    • @commandercaptain4664
      @commandercaptain4664 2 роки тому +130

      Tell the horses they're being sold, and the three that don't get caught are the fastest.
      #OrwellWuzHere

    • @Movie2Documentary
      @Movie2Documentary 2 роки тому +7

      "And then they burst out in laughter."

    • @andreymontag
      @andreymontag 2 роки тому +30

      When you apply to Google, but it's economics dpt and not IT

    • @toskano1509
      @toskano1509 2 роки тому +5

      This is elon musk

  • @ypob2007
    @ypob2007 3 роки тому +675

    I am not getting smarter, i am just upgrading my memory over puzzles for when i do a job interview in like, four or five years

    • @TheRealInscrutable
      @TheRealInscrutable 3 роки тому +37

      If they ask questions like this you do NOT want that job.

    • @BrooksMoses
      @BrooksMoses 3 роки тому +29

      @@TheRealInscrutable : Agreed. Speaking as someone on one of Google's hiring committees, we don't ask interview questions like this. :)

    • @LivingAmnesia
      @LivingAmnesia 3 роки тому +35

      Job interview questions are simpler and shorter. Tom has 3 apples and Mark has 2 apples. Calculate the distance between Earth and the Sun

    • @ypob2007
      @ypob2007 3 роки тому +14

      @@LivingAmnesia the answer is 7 cars

    • @Krasses
      @Krasses 2 роки тому +4

      @Dpg Dpg You didn't calculate it, you looked it up. Sorry you don't pass
      In order to calculate it, you must take drag a line from the edge of the earth to the edge of the sun

  • @ang5798
    @ang5798 11 місяців тому +9

    I got stumbled at "5 races give five " Fastest" Horses from each group, and the fastest among them is the first overall. But how exactly do I proceed with the 2nd and 3rd? " And I am happy about your explanation

  • @kiii9403
    @kiii9403 11 місяців тому +66

    Mechanical horses make so much more sense, in the beginning I was thinking of actual horses where you'd have to consider how many races each individual horse ran to make it fair in comparison

    • @dragndorf9
      @dragndorf9 9 місяців тому +2

      lol

    • @silphv
      @silphv 9 місяців тому +11

      Yeah this generally applies to a lot of tech interview questions: there might be a simplifying assumption that needs to be made, and it won't always tell you what that is. If horse performance is variable, the question doesn't really have an answer, or it has a complicated answer with probabilities. With the information that's given, always take the simplest version of the question you can-that's usually what's intended. You can explain: "Based on the wording of the question, I'll make a simplifying assumption here that each horse can be mapped to a single numerical speed value, and it doesn't change between races". That's the kind of thing an interviewer is looking for, it shows that you see how complicated it *could* get but you know you don't have enough information for that to be the intended question.

    • @EileenTheCr0w
      @EileenTheCr0w 8 місяців тому +2

      Yeah, in the real world there is no perfect solution, because the horses might perform better or worse on a given race for different reasons.. the dead slowest horse could be sick but normally be the best, some may have more stamina and thus do better in later races, etc..

  • @momamilosevic2465
    @momamilosevic2465 3 роки тому +697

    Google: Which 3 of those 25 horses are fastest?
    Meanwhile on bing: Leave only 3 alive

    • @scantyer
      @scantyer 3 роки тому +8

      LMAO

    • @TimCizej137
      @TimCizej137 3 роки тому +5

      LOL

    • @stevenmorris3181
      @stevenmorris3181 2 роки тому +3

      That leaves you with the slowest three. You would have to have four left to give it a possibility

    • @momamilosevic2465
      @momamilosevic2465 2 роки тому +5

      @@stevenmorris3181 but they would be fastest three too, right?

    • @stevenmorris3181
      @stevenmorris3181 2 роки тому +3

      @@momamilosevic2465 Accidently killed the top 22...These things happen

  • @puzzLEGO
    @puzzLEGO 2 роки тому +2235

    for people getting 6 races, we’re trying to find a method which guarantees the top 3 horses will be found. after the first 5 races, there are 15 horses which could still potentially be top 3 overall, and after the 6th race, there are still 5 in contention, including some of those 15 who didn’t win their initial race.

    • @ilikefarting
      @ilikefarting 2 роки тому +426

      I do not give a crap it is six for me

    • @frommelow
      @frommelow 2 роки тому +128

      @@ilikefarting edgy

    • @ilikefarting
      @ilikefarting 2 роки тому +7

      @@frommelow exactly how

    • @deemcgann1695
      @deemcgann1695 2 роки тому +399

      @@ilikefarting "I dont care if i was proven wrong i still think im right"
      this is why humanity has SO many problems

    • @ilikefarting
      @ilikefarting 2 роки тому +82

      @@deemcgann1695 is this math problem a 1st world problem? also it was an obvious joke

  • @csandford
    @csandford 8 місяців тому +1

    Interesting puzzle. I didn’t initially find the explanation very helpful, except it made me question my initial answer until I could work out the solution. Good stuff.

  • @mrbigheart
    @mrbigheart 8 місяців тому +2

    This is damn good, man!
    Until I saw the visual elimination and the surprise at the end (that we don't need to race again the fastest horse) I couldn't wrap my head around it.
    Thank so much!!!

  • @Oakenlix
    @Oakenlix Рік тому +523

    I realized pretty quickly that 6 races isn't enough, at which point I decided it's to complex and might require like 20 races or something.
    Glad to see such an elegant solution, thank you!

    • @KittSpiken
      @KittSpiken Рік тому +5

      So close

    • @dakshsmy
      @dakshsmy Рік тому +5

      That was my exact chain of thoughts

    • @champu823
      @champu823 Рік тому +10

      I got 11 races lol

    • @galacticlava1475
      @galacticlava1475 Рік тому +21

      Why isn’t it 6? When you run the 6th race full of the winner horses, the 1st 2nd and 3rd places would be the fastest horses, right?

    • @guanlin0
      @guanlin0 Рік тому +32

      @@galacticlava1475
      2nd place horse in 6th race might be slower than second place from the race the first place horse raced in.
      for all we know, that specific race might have consisted of the 5 fastest horses in the herd.
      thats why we take the 2nd and 3rd horse from that group, because even if 2nd place horse in race 6 is faster than 2nd place horse in race with the overall fastest horse, it may still be slower than 3rd place horse in that race.
      you consider the 2nd place horse in the race producing the 2nd fastest in the 6th race as u want to find the top 3 horses in speed, as 2nd place horse in 6th race might be faster than 2nd place horse in race that produced the fastest horse.
      Lastly, u include no3 from 6th race as all these extra horses included can still be slower than it, and if so, u still have ur fastest 3.

  • @teejfalconaf
    @teejfalconaf 3 роки тому +455

    This only works for spherical horses in a vacuum.

    • @backwashjoe7864
      @backwashjoe7864 3 роки тому +35

      best to make them frictionless, spherical horses in a vacuum :)

    • @sifter14
      @sifter14 3 роки тому +3

      @@backwashjoe7864 lmao how do they run?

    • @danielburgess7101
      @danielburgess7101 3 роки тому +30

      And all collisions are elastic

    • @theSpian1
      @theSpian1 2 роки тому +15

      ideal horses too, so individually they have no volume but occupy a finite space together.
      They also do not attract each other so little ponies won't be made

    • @thombruce
      @thombruce 2 роки тому +8

      @@backwashjoe7864 I’d argue that being frictionless and in a vacuum were redundant, but…
      Instead I’m going to add that they should also be made up of non-baryonic matter so as not to be affected by virtual particles.
      Frictionless non-baryonic spherical horses in a vacuum.

  • @askmiller
    @askmiller 9 місяців тому +2

    Locking in my answer: After racing 5 sets of 5, you can eliminate the 2 slowest of each set of 5. Then if you race the tops from each set, you can eliminate everything from the worst 2 sets of 5. You now know the fastest. The remaining 2 horses from the set whose winner ranked 3rd can be eliminated and the 3rd place of the set whose winner ranked 2nd can be eliminated, leaving the battle for 2nd and 3rd between the 2nd and 3rd from the set whose winner was the best, the 2nd place horse of the 2nd place among winners, and the 3rd place among winners. Race those 5 horses, find the top 2 and they are your 2nd and 3rd. 7 races total.
    edit: nailed it :)

  • @GoDaveGo
    @GoDaveGo 11 місяців тому +24

    I got it! I checked a couple methods that ended at 11 races, but was brute force. So I drew a picture similar to yours and got to seven

    • @sadlittleking2570
      @sadlittleking2570 11 місяців тому +6

      I came up with 11 as well just doing it my head. Might have came up with seven if I wrote anything down to really visualize it.

    • @BURN-ADDiCT
      @BURN-ADDiCT 10 місяців тому +2

      ​@@sadlittleking2570 same here.
      The 11 is so convenient, I hadn't thought that visualizing the problem can help

  • @brianvalenti1207
    @brianvalenti1207 3 роки тому +3105

    As an employer, this is the answer I want: "We need a watch so we won't have to waste time with unnecessary horse races"

    • @JonathanMandrake
      @JonathanMandrake 3 роки тому +104

      And it is open to interpretation, so some will interpret it in a way so you can label the horses and get 7 races, others will not label them and get 11 races. I would think a good answer would also be that the instructions are not complete

    • @bro748
      @bro748 3 роки тому +197

      If you are looking to hire a programmer that's definitely not the answer you're looking for. If this were a simulation it would take less resources to program this solution in than to program in a clock. Programmers have to always think abstractly to find the most practical solutions.

    • @Ghorda9
      @Ghorda9 3 роки тому +83

      except you actually make more money having more races, the house always wins.

    • @brianvalenti1207
      @brianvalenti1207 3 роки тому +35

      @@bro748 That's also a very good answer. Also, if I hired a programmer, the only reason I'd have them out racing horses without proper equipment, would be as a punishment. Or maybe as a reward, depending on the programmer.

    • @somebod8703
      @somebod8703 3 роки тому +78

      @@bro748 If you are looking to hire a programmer, you want to get a solution that does not blow up in your face when you get a 26th horse and the algorithm is just not working anymore. So you should phrase this as a more general problem with N horses. And then it gets interesting whether you want to find a generalizable algorithm that performs well on both low and high numbers or something that switches in between.
      Adding a clock scales nicely O(n), which is the best you can get with this, so this is actually one of the best answers. :P

  • @VideosDeGatwinOficia
    @VideosDeGatwinOficia 6 років тому +1924

    I knew it with cows, that's why I couldn't solve it.

  • @ernstbrubaker
    @ernstbrubaker 9 місяців тому

    The power of good notation! Awesome!

  • @gekkkoincroe
    @gekkkoincroe 8 місяців тому +4

    I shot 22 horses and remaining 3 were the fastest , i don't need no watch but a shotgun is a must

  • @jenniferkeeponfighting7561
    @jenniferkeeponfighting7561 2 роки тому +598

    I think it also depends on who is keeping track and actually watching the races. Alice or Bob would be able to figure it out. Charlie is either selling popcorn or shoveling the stalls.

    • @crashoverwrite5196
      @crashoverwrite5196 2 роки тому +11

      the answer he gave is not correckt! The problem is that you dont have a time/ watch nor a distance! If you let 5 groups run, and you take the 1st. of each group, you can not be sure if these horses are one of the fastest 3. 1st horse in group (a) maybe can run just 2Kmh and the 1st of group (c) can run 40kmh while 2nd of group (E) can run 60 kmh! . you have to have a constant to really get the 3 fastest! My logic: So you let the first 5 race, then you let the first second and third place on the track and get 2 new ones in, every race the 4,5 will be replaced. with this method you have always a constant for first, second and third place without needing a watch ! each race, 11 in total , will naturaly eliminate 4 and 5 place ! imagine this: lets say the first group are the 5 slowest of all, so the slowest up to the 5th slowest of all. in the second race the 4th and 5th place gets replaced with (in this simplyfiyed case)faster ones, and maybe one is the fastest of all and the other one the 2nd fastest of all. they will be 1st and 2nd place of the 2nd race and they will stay on this position. the 3th will be found after all other races are finished. You can switch the start situation, that the first 5er group have two of the fastest of all in it, so the first and second place will be set after the first race, and again the other races and just to find the real 3th place.---- i think its 11 races ! 😃

    • @charlesmeng4513
      @charlesmeng4513 2 роки тому

      hahahahaha~

    • @Lurklen
      @Lurklen 2 роки тому +7

      Goddammit Charlie! Who keeps hiring this guy?

    • @sodiboo
      @sodiboo 2 роки тому +16

      @@crashoverwrite5196 > 1st horse in group (a) maybe can run just 2Kmh and the 1st of group (c) can run 40kmh while 2nd of group (E) can run 60 kmh!
      No. If you look carefully at the solution, the groups "a, b, c, d, e" are named *after* the 6th race. the winner of group a is the 1st place of the winners, the winner of group b is the 2nd place of the winners, so by definition a_1 > b_1 > c_1 > d_1 > e_1 - and then, you have a tree from the winner, you only want the top 3 so you can eliminate any that are 4th or more from the winner, and you are left with exactly 5 horses to race and find the 2nd, 3rd overall

    • @crashoverwrite5196
      @crashoverwrite5196 2 роки тому +5

      @@sodiboo You dont know how fast they are! so my asumtion is valid. You need a fix point for the 1st,2nd and 3rd place. my comment was based on the crux, not the solution he gave.

  • @simonmultiverse6349
    @simonmultiverse6349 3 роки тому +264

    Shoot 22 of the horses. By definition, you will be left with the 3 fastest.

    • @WesbirdlyO
      @WesbirdlyO 2 роки тому +19

      That's a tad psychotic, but damned if it isn't the sort of off-the-wall answer Google would hire you for.

    • @DreadX10
      @DreadX10 2 роки тому +34

      It was 'RACE the horses', not 'ERASE' !
      You had one job......

    • @ozzygilliam9194
      @ozzygilliam9194 2 роки тому +6

      @@DreadX10 race horses in sets of 5 and kill the ones not 1st place, 5 races.
      Race remaining horses and kill 5th and 4th place. 6 races.
      You are now certain that the 3 horses you picked are the fastest of the original 25.

    • @theempath8244
      @theempath8244 2 роки тому

      Got to laugh at this one.

    • @simonmultiverse6349
      @simonmultiverse6349 2 роки тому +1

      @@ozzygilliam9194 ...but two or three of the fastest horses might (by chance) be in your group of 5, so then you would have shot one or two of the fastest horses.
      you could race them in groups of 5 and the two slowest are retired (see Blade Runner).

  • @scouter-xn6zi
    @scouter-xn6zi 8 місяців тому

    Nice problem. I liked the step-2 explanation very much.

  • @Fabulous_Facade
    @Fabulous_Facade 10 місяців тому +5

    Love your method. I somehow got 12 by ruling out the horses that were not the fastest.

    • @roxterat
      @roxterat 10 місяців тому +1

      You'd get to 10 that way, but I did the same..
      (25 - x * 2 = 5, since you need final 5 to race. x equals 10.)

  • @Parlik
    @Parlik 3 роки тому +419

    Kill 22 of the horses, then by default the remaining 3 must now be the fastest

    • @brianvalenti1207
      @brianvalenti1207 3 роки тому +20

      So you're proposing mass destruction of company property during an interview?

    • @Aniaas1
      @Aniaas1 3 роки тому +81

      @@brianvalenti1207 I think you mean "streamlining equestrian surpluses"

    • @abhiramp7094
      @abhiramp7094 3 роки тому +3

      You would never get a job with that I guess ...

    • @williamlevison9966
      @williamlevison9966 3 роки тому +16

      @@abhiramp7094 Hey, this man just solved how to prevent a food shortage. He must be hired.

    • @gumo77
      @gumo77 3 роки тому +5

      @@Aniaas1 Cultural fit: 4.0

  • @smilergrogan1452
    @smilergrogan1452 3 роки тому +336

    I'm the interviewer, I'm now wishing I'd never asked this question after hearing 27 variations of how to solve it. It's late Friday and I want to finish work. . . . . . .First one to tell me, 'Sell 22 of them, keep the cash!' Gets the job! I don't care, I'm retiring next week.

    • @apollyon1
      @apollyon1 3 роки тому +24

      I said shoot 22 horses but this is so much better!

    • @knuckledick487
      @knuckledick487 3 роки тому +4

      Hey its been a few weeks. How is the retirement going?

    • @simonmultiverse6349
      @simonmultiverse6349 3 роки тому

      @@apollyon1 So did I!

    • @shambhav9534
      @shambhav9534 3 роки тому +4

      What has happened about retiring next week? Are you so busy making the papers ready that you forgot you had announced your retirement publicly on UA-cam?

    • @CenturionDobrius
      @CenturionDobrius 3 роки тому

      @@apollyon1 ingenious :)

  • @Spioctius1
    @Spioctius1 8 місяців тому

    I paused the video after hearing the instructions and after about 7-8minutes I got it right. Super cool puzzle

  • @user-su4dd9kp7l
    @user-su4dd9kp7l 11 місяців тому

    Got it within like 30 seconds. This is like a low level Leetcode medium. Probably one of the easier questions Google would ask nowadays.

  • @Nascarnate100
    @Nascarnate100 Рік тому +570

    I was getting 9 as a first effort but then as soon as you said 7 I was able to figure out how to get 7… It’s truly wonderful how much knowing that something can be done can influence your ability to do that something

    • @DanielScholtus
      @DanielScholtus Рік тому +5

      Same here

    • @wesleyowens4089
      @wesleyowens4089 Рік тому

      I did the same thing as well

    • @thoubias
      @thoubias Рік тому

      exactly the same words

    • @ps3737
      @ps3737 Рік тому +3

      Just like our full potential as a living being. Very few people know this and it then makes it impossible to achieve it until you are taught it by someone who has achieved their full potential. Most believe it is impossible only because they don't know how.

    • @Mr.Verethron
      @Mr.Verethron Рік тому +6

      "Knowing where the trap is-that's the first step in evading it" ― Frank Herbert, Dune

  • @brianhelgerson87
    @brianhelgerson87 2 роки тому +345

    Anyone that can use the logic this guy does to answer an interview question like this is probably too good for the job, anyway.

    • @hhhhh7282
      @hhhhh7282 2 роки тому +2

      I dont really think so maybe he is or maybe he is not

    • @digiquo8143
      @digiquo8143 2 роки тому +55

      It's a programming problem, ie why Google would ask it to a potential employee. It doesn't really matter what horse is the 1st, 2nd, and 3rd fastest, they're trying to get you to come up with a problem-solving technique to identify what those horses are. Programming is all about developing these techniques, the actual numbers/results don't matter so long as the techniques are correct.

    • @nobodyknows3180
      @nobodyknows3180 2 роки тому +16

      @@digiquo8143 Agreed. There are all kinds of videos on you tube (including several other of the 25 horses problem) that pose intriguing puzzles that challenge your brain to think, find possible solutions, look at possibilities, and come up with sound techniques that will work in any case.
      Someone else here mentioned six races, and when I worked through his logic, I found out that he was in fact correct, but it only worked in 2 possible cases, both of which were statistically insignificant. The correct technique, as shown in this video, will hold up rigorously for all cases.

    • @Aaron.Aguilar
      @Aaron.Aguilar 2 роки тому +1

      @@digiquo8143 results matter if there are many results, i.e. many applicants for 1 job

    • @nomoremrniceguy8106
      @nomoremrniceguy8106 2 роки тому

      @@nobodyknows3180 nah man

  • @DarknessDpa
    @DarknessDpa 7 місяців тому +3

    I can see now how this effectively works thanks to the explanation but when I attempted to solve this, I instead raced 5 horses to start and then took the horse who got first place and race it again with 4 new horse which by racing all horses would take 6 races all together but this of course only reveals the fastest horse and not 2nd or 3rd.
    Still while I didn't fully get it I do like how I thought of an alternate way to probably just find the fastest horse rather than the more simpler way.

    • @francaborgonje7747
      @francaborgonje7747 5 місяців тому +1

      I did it like this too. And I still think it does show the minimal number of races needed. You can be sure of your top 3 after 6 races if you are lucky. If in your sixth race you have two horses that are faster than the fastest of all previous ones.
      If you are not lucky you will need extra races to be sure. And this proces differs on how often you had to change your top horse.

  • @Julez-
    @Julez- 10 місяців тому

    Beautifully explained

  • @MrVirus9898
    @MrVirus9898 3 роки тому +721

    There are ways to learn this in 0 races. Consider disassembling one horse, reverse engineering its software to find where the horses movement rate is located, then hack the other 24 horses and learn their rates without the horse moving.
    The question is "The three fastest horses" not "Rank the horses by the fastest" Another way is to destroy all but three of the horses, and then you automatically know the three fastest horses.

    • @thekeeper8820
      @thekeeper8820 3 роки тому +65

      Technically correct, the best kind of correct.

    • @heberthr.6978
      @heberthr.6978 3 роки тому +23

      Horse murder

    • @absolstoryoffiction6615
      @absolstoryoffiction6615 3 роки тому +2

      For machines... Yeap.

    • @wiltmarlonelao
      @wiltmarlonelao 3 роки тому +34

      "...destroy all but three of the horses."
      *hold up*

    • @junj1023
      @junj1023 3 роки тому +1

      @@heberthr.6978 Vc aqui? Pensei que só assistia o Tadeu

  • @HWPcville
    @HWPcville 2 роки тому +427

    I came up with 8 races and proved it using pennies as horses. I didn't consider the 7th race could determine both the 2nd and 3rd fastest horses by eliminating the entire field of horses that only had 1 winner (race 1 -5). Thanks for posting.

    • @mrnoobpianist8564
      @mrnoobpianist8564 2 роки тому +4

      Even i got 8 as my answer

    • @MrSupdup
      @MrSupdup 2 роки тому +6

      I got 8 as well, but then when I saw the actual solution was 7 I immediately noticed we repeat the 7th and 8th race with the bottom 2 horses that have absolutely no hope of ever winning a top spot, and so worked out the best solution from there. So I worked out how to do it in 7 after seeing the solution was 7, but before seeing how to do it.

    • @darrylbrookes2780
      @darrylbrookes2780 2 роки тому +2

      @@MrSupdup for some reason i kept looking for the top 5 fastest horses haha
      needed them place bet odds i guess

    • @Unearthly89
      @Unearthly89 2 роки тому +4

      I also got 8. It is easier to find a solution that is not optimal, but that is fine in computer science. After you found a solution that works, you should seek to find a better solution, if necessary. 👍

    • @sasino
      @sasino 2 роки тому +5

      I got 6, but I was wrong. I assumed the first 3 winners of the 6th race were the 3 fastest, without considering that they hadn't raced yet against those of higher level

  • @fwiffo
    @fwiffo 10 місяців тому +1

    Google doesn't actually use these sorts of logic puzzles in interviews. At least they haven't for the last 20 years or so. They ask algorithmic/coding questions, system design questions, questions that check technical knowledge and the like. There are lots of videos posted by Google about how to prep for a Google interview. But tl;dr, re-read Introduction to Algorithms (AKA the mobile book).

  • @mehulajax21
    @mehulajax21 11 місяців тому

    I came up with similar notation and same answer. I 1st worked all in my mind and came to 8...
    Then to verify, i drew it down and realized there was a slight error in my mental picture and concluded its 7. Then I saw your solution and was happy that I almost solved it in my mind. Will practice a bit more visualization techniques...

  • @Gid-J
    @Gid-J Рік тому +535

    I just want to say, your question is exponentially better than the common interview question. Me sitting here with tired horses, one fell in a race....

    • @fmobus
      @fmobus Рік тому +16

      there's nothing exponential about this. Exponentially doesn't mean "a lot more".

    • @EnderFlop
      @EnderFlop Рік тому +78

      @@fmobus i bet it gets girls at the club reeeal hot when you tell them that

    • @Mo_Egan
      @Mo_Egan Рік тому +43

      ⁠@@fmobus you do understand what an exponential equation looks like right? Calling something exponentially better is in comparison to calling it linearly better, where something exponentially better reaches its limit faster than something that reaches its limit linearly. So “exponentially better” means “a lot better” and “exponentially more” means “a lot more”…

    • @asianman1441
      @asianman1441 Рік тому +13

      ​@@fmobusAre you the type of kid who tries to correct a teacher?

    • @ahaaha8462
      @ahaaha8462 11 місяців тому +1

      It’s a classic quant question

  • @johnallegood4469
    @johnallegood4469 3 роки тому +374

    Lazy solution: run 11 races and eliminate the 2 slowest each time. 22 eliminated, all that's left are top three

    • @Jri3102
      @Jri3102 3 роки тому +72

      This is the correct answer because there is no fact that the 2nd, 3rd, and 4th heats are any faster then the first three winners.

    • @BogunFabian
      @BogunFabian 3 роки тому +14

      This is what I came up with

    • @jonwicked7031
      @jonwicked7031 3 роки тому +2

      I get a paper and label the horses so and I based my time on the fastest one in each group so then I can tell which ones are the fastest Ones ( I will race the fastest of each group to see which one is the absolute fastest and based the speed on that one

    • @mike7546
      @mike7546 3 роки тому +2

      My best answer would be run a horse race gambling game while doing the laziest solution done everyday making sure to keep horses always healthy, do it for 6 months to a year, you get money and you get the best horses trained after months of running 🥳.
      Since the fastest horse now wont necessarily be the consistently fastest horse, you need reliable statistics!

    • @BypassOne
      @BypassOne 2 роки тому +22

      That's actually the correct answer, because it's said you don't have a watch, so you could never compare the times of each group's fastest horses, 2nd, 3rd, etc (one race at a time, remember?) The 2nd place from group A may be faster than group B's fastest horse.
      The guy who made this video may be good at math, but he surely lacks text interpretation...

  • @Epic-1224
    @Epic-1224 Місяць тому

    Finally a question I answer it correctly.
    But it's unrealistic they assume the horse will run the same speed everytime.

  • @konstantinkurochkin5695
    @konstantinkurochkin5695 11 місяців тому

    Thanks, very interesting , and t's clear to understand!!!

  • @bunkerputt
    @bunkerputt 2 роки тому +45

    This is something I learned in grad school. For any top-N problem, the tournament algorithm produces the minimal time solution, same O-notation complexity, but lower constant factor due to decreased pairwise comparisons.

    • @paytonj2620
      @paytonj2620 2 роки тому +1

      The general extension of this algo would have been an excellent interview question with a runtime and proof of completeness. It felt good to know I got this one right when I did it.

  • @austinhenkel3569
    @austinhenkel3569 Рік тому +725

    So something we talked about in economics the other day is how if you take too much time to solve a problem in the most efficient way it can be more costly than just doing the inefficient way that instantly comes to mind. The answer I came up with was 11. I know it’s not even close to 7 but if I was able to have a system ready in 10 seconds that works I’m still proud of that answer
    Edit: very happy with the conclusion of the video though. Super cool thought process!!

    • @Stubbari
      @Stubbari Рік тому +72

      But then again, if you spent a bit longer thinking more efficient solution you would save 4 races.
      That's 20 races you would have saved those mechanical horses from doing. If you do this more than once the maintenance costs are going to pass your thinking time.

    • @tobal7020
      @tobal7020 Рік тому +12

      well, this makes sense to me, but i think that if u create the best solutions u will be faster to create the best solutions next time and everytime, and maybe just at the start is harder, maybe

    • @HibiTeamQueso
      @HibiTeamQueso Рік тому +37

      Depends on the context. If it's a one time thing then sure but if you have to compare horses thousands of times then you have to use the better answer

    • @Coen80
      @Coen80 Рік тому +9

      I think he is wrong, he would not be hired by Google. (About the answer in the video)
      I think he assumes that all horses finish at equal time intervals. The fastest horse, without any timing available, doesnt say anything aboit the slowest horse.
      The horse that finished 2nd to the fastest of all horses (the fastest group) could still be slower than the horse that finished 2nd to the horse that finished #5 in the 'race of winners'
      So without also determining which are the slowest horses this is just assumption.
      I'd say one need at least 8 races therefore.
      11 is making sure anyway. Cross reference and you can make the whole top25.

    • @Stubbari
      @Stubbari Рік тому +32

      @@Coen80 With 7 races you always identify the three fastest horses

  • @ZimCrusher
    @ZimCrusher 9 місяців тому +1

    Running through this pretty quickly, I got 11 races. 5 horizontal, 5 vertical, then a final race to determine the order.
    Love the logic in this. Shortest route to the best answer.

    • @yurenchu
      @yurenchu 9 місяців тому

      Which horses would you pick for the final race?
      By the way, the order of the three fastest horses is not required.

    • @ZimCrusher
      @ZimCrusher 9 місяців тому

      @@yurenchu I was over complicating the puzzle. It makes it a lot easier when you are allowed to reshuffle based on performance.

    • @yurenchu
      @yurenchu 9 місяців тому

      @@ZimCrusher Sorry, but what are you talking about, "when you are allowed to reshuffle based on performance" ? And first you said "Shortest route to the best answer", and now it's "I was over complicating the puzzle" ?
      And why aren't you simply answering my question: which horses would you pick for the final (= 11th) race?

    • @ZimCrusher
      @ZimCrusher 9 місяців тому

      @@yurenchu When I ran my solution, I would always end up with overlap.
      Meaning, There would be horses that won both vertically, and horizontally, in the final count, so there would only be 6 horses remaining. I would run the horses that won both races, and then just fill in the race with 1-2 of the single entries. This always gave me the top 3, but I only ran it 100 times.
      Looking, now at my code, it should have given me a few end results where one of the top 3 was left out.
      So... my solution fails as a perfect solution, not even counting that I needed 11 races, to their 7.

    • @yurenchu
      @yurenchu 9 місяців тому

      @@ZimCrusher Thank you for your reply and your explanations.
      Ah, now I get it. Previously I assumed that when you said "vertical", it meant that after the first five races, the first place finishers raced against eachother in race 6, the 2nd place horses raced against eachother in race 7, the 3rd place finishers raced against each other in race 8, and so on. Because that was an approach that was suggested by another commenter that I vaguely still remember. I didn't understand that you meant "vertical" as in how these 25 horses were arranged in a 5-by-5 matrix from the start, before any races were run.
      That makes the analysis interesting but much more complicated though. And yes, it appears that there would be scenarios where one of the Top3 would be left out (in 11 races), since after the first ten races, it's possible (for example) that the #3 fastest horse overall has lost both of its races (and hence dodges "detection"/won't be selected for the 11th race), while five other horses have won both of their races.
      Anyway, thanks for your reply.

  • @byrne1807
    @byrne1807 6 місяців тому +9

    Fun question! I initially got 8, using the basic outline for the solution but was just racing the 2nd place race from the one with the fastest horse against the other 4 again for 7, and then used my 8th to run the next fastest from the group with the second fastest horse against the remaining 4. Was able to get the solution method after seeing the answer was 7, but not sure if I would’ve seen the optimization on my own, at least not without a pencil and paper

  • @andrelaszlo
    @andrelaszlo Рік тому +450

    I came up with the optimal solution in a few minutes with pen and paper, but I guess it's easy to get stuck if you miss some piece of information.
    I thought it was easier to think backwards: first you definitely need 5 races to race each horse once. The two slowest horses from each race is definitely not part of the top 3.
    You are now left with five groups with three horses (15 in total). You don't want to race them all against each other, so you can rank the groups relatively to each other by racing the slowest or the fastest in each group. Since we're looking for the fastest ones, intuitively it makes more sense to rank by the fastest, so we race the fastest horse in each group in the semifinal.
    All the horses in the two groups represented by the last two horses in this race will all be slower than the fastest three horses in this race. We're left with three groups, with three horses in each (9 in total).
    Some observations at this point:
    - The fastest horse is identified, as the fastest horse from the semifinal
    - There are three ways that the three fastest horses can be arranged into the three fastest groups: the top three from the fastest group, the fastest horse plus the two fastest horses in the second fastest group, or finally the fastest horse in each of the three fastest groups.
    This gives us 6 candidates for the three fastest horses. Realizing that the fastest one is already identified leaves us with five horses to race the final.
    The two fastest horses in the final are the second and third fastest horses.
    Alternative solutions:
    - 1 race: Race 3 randomly selected horses. The other ones have never competed so their time is undefined.
    - 0 races: Shoot 22 horses.

    • @cooldud7071
      @cooldud7071 Рік тому +16

      Professor Layton ass solutions

    • @alphaomega5169
      @alphaomega5169 Рік тому +3

      thats dark men

    • @thomgizziz
      @thomgizziz Рік тому +4

      I got 8 races in 10 seconds and no paper...

    • @cooldud7071
      @cooldud7071 Рік тому

      @@thomgizziz Same

    • @kevinlorimer
      @kevinlorimer Рік тому +4

      I got the same result with the same reasoning, except note that when you say "there are three ways..." there are actually four; you could also have the fastest horse, the second fastest horse from that same group, and the fastest horse from the second fastest group. That doesn't change anything about the rest of your explanation though :)

  • @MindYourDecisions
    @MindYourDecisions  7 років тому +312

    Help make this channel better!
    1. If there's a "hard" problem or any math topic you want covered, please let me know. Preferably send me an email--my address is listed on my blog and in the channel's "about" tab. I do extensive research so it takes me months to make some videos. The Google 25 horses puzzle, for example, was from an email I got in October 2016.
    2. I'm open to better video titles. If you do not like the title, suggest a better one. If enough people upvote it I will see it and consider changing the title.
    3. I have fulfilled almost every suggestion from supporters on Patreon (www.patreon.com/mindyourdecisions). If you make a pledge, even for $1 a month, it goes a long way to supporting videos that would take a long time to make but would get very few views.
    4. How do you feel about sponsors in videos? I ask since I personally get annoyed at seeing sponsors in a lot of the videos I watch. But I also understand creators need sponsors to make a living. I get many emails asking for sponsorship and I have passed on them for your sake. I'm curious what you think before I make a decision.

    • @bibo2728
      @bibo2728 7 років тому +74

      It is actually the wrong solution, Because:
      Lets use group a as an example, The slowest horse in group a could still be faster than all the other horses in the other groups, even the winners in b,c,d and e. Same as the slowest horse in b could be faster than the fastest horse in the other groups. Thefastest horse overall though is calculated the right way but you need more races to see who is the fastest of the slowest then compare the slowest to the fastest to see if they are quicker than the fastest in the other group. Since each horse is individual and not counted as group of five, your solution of 7 races must be wrong. If you understand what I meant

    • @jamesh2649
      @jamesh2649 7 років тому +27

      PeacefulMiner this is exactly what I was thinking. All of the horses in group A can be faster that the fastest from B or C and all the horses from group B can be faster than the fastest horse in group C.
      The elimination is flawed or I need more explanation.

    • @Sagand42
      @Sagand42 7 років тому +34

      But in group A the slowest horse has already finished 5th in a race therefore can't be one of the three fastest horses. Same same logic applies the 4th fastest in that group.
      In the second group the horse that finishes 3rd is slower than two horses in it's own group and the fastest from group A (which you agree is fastest overall) so it can't be in the top three.
      The horse than finishes 2nd in group C is slower than the fastest in group C, the fastest in group B (as the fastest in group B beat the fastest in group C) and the fastest in group A so also can't be in the top three overall.

    • @seyberbuchan2182
      @seyberbuchan2182 7 років тому +21

      I got 6 because five races then the three fastest will be the three winners of the sixth race

    • @insanitycubed8832
      @insanitycubed8832 7 років тому +6

      Step 5. get the right answer, it's six if you want my proof I'll give it.

  • @adrianhjordan1981
    @adrianhjordan1981 11 місяців тому +1

    I wish they asked this sort of question in my profession.
    Instead they'd ask me to give an example of a time when I had to tell someone that their horse was not going to be one of the fastest three horses and what tools I would use to help me do so.

  • @Petrkowal
    @Petrkowal 11 місяців тому

    Nice, finally one of those questions I could solve myslef xD

  • @rene0
    @rene0 3 роки тому +627

    Lazy programmer to Google: `Just run 11 races and leave optimization for problems with 25 million horses.'.

    • @JonathanMandrake
      @JonathanMandrake 3 роки тому +35

      I don´t know if you are even allowed to label the horses, since it is not said you can. And if you can´t label the horses, 11 horses is the right answer, because every race exactly 2 horses can´t go on for further testing. It all depends on the interpretation of the questions.

    • @bollejoost
      @bollejoost 3 роки тому +18

      yeah i think 11 races is the common answer

    • @marvalice3455
      @marvalice3455 3 роки тому +6

      @@JonathanMandrake thats the "you aren't good enough" answer

    • @a0flj0
      @a0flj0 3 роки тому +7

      That's sometimes a good approach - when the optimization is a complex process. But in this case the optimization is simple enough that there's no reason not to use it on small numbers of horses too.

    • @Subtekjr
      @Subtekjr 3 роки тому +7

      @@a0flj0 Sure, but without knowing this answer beforehand, who is actually going to think about this? Google should want to see that you know how to solve a problem in front of you, not necessarily do it in the best and most accurate way possible.
      In real life you'll have resources to assist you in researching what the best way to do something is. You're not just given an issue and told to fix it immediately without any outside help.

  • @chinadan86
    @chinadan86 6 років тому +342

    After watching this video, horse neither looks or sounds like a word anymore

    • @mravenger20
      @mravenger20 6 років тому +8

      wow whar a relief I'm not the only one!

    • @matrixphijr
      @matrixphijr 6 років тому +3

      Buffalo buffalo buffalo buffalo... Oh wait, that’s something else.

    • @dogestdoge7097
      @dogestdoge7097 5 років тому +16

      Vsauce! Michael here. What you experienced is what we call "Jamais Vu". It's what you experience when a word has been spoken so many times that it loses its meaning. Thanks for watching, this has been Michael... or am I?

    • @harsha5774
      @harsha5774 3 роки тому +2

      yeah its called semantic satiation

    • @khajiitimanus7432
      @khajiitimanus7432 3 роки тому +2

      I relate to this on an existential level with other words.

  • @pedrosilveira2972
    @pedrosilveira2972 8 місяців тому +5

    The answer is 0. Kill 24 horses and the one left is the fastest as the others can't run.

  • @liamn2030
    @liamn2030 12 днів тому

    Another way to think of it is that for the fastest 3 horses, they must be slower than no more than 2 other horses. The only horses that fit this criteria are the top 3 horses in the initial race with the winner of the race winners, the top 2 in the initial race with the 2nd place in the race of race winners, and the 3rd place in the race of race winners. That's 6 horses, but the winner of race winners must be the fastest, so you only need to race the remaining 5 and take the top 2 of that 7th race.

  • @SaintNine
    @SaintNine 2 роки тому +71

    I made it seven, but it was a bit of a guess. I got as far as racing five groups of five and then racing the winners, giving six races. After that I figured one more race should do it, but more by intuition than reasoning. The step that eluded me was that any horse beaten by three others could be eliminated, although that seems obvious, now you mention it. I think I would have got there eventually, but it's easy to say that and my working would most likely have involved some extra unnecessary steps. Thanks for the clarification 🙂

  • @12345themadguy
    @12345themadguy Рік тому +108

    Something i think could be explained as i didnt initially think of it and other ppl dont seem to have noticed is the fastest horse of a given race could still be slower than the slowest horse in another race. Just depends on luck of the initial groups

    • @willowofwildwoods
      @willowofwildwoods 10 місяців тому +17

      I was thinking about this too, but with this method, it won't matter. Even if the horses are arranged strictly by performance (the slowest in group A is faster than the fastest in group B), it will just mean that the winners of race 7 (2nd and 3rd fastest overall) will all come from group A

    • @crisvamc83
      @crisvamc83 10 місяців тому

      Better to put forward with timings .... I mean minutes and seconds

    • @Neverendless92
      @Neverendless92 10 місяців тому +1

      ​There is another problem in every race the horses are randomly asigned and you don't have the time so by that definition in one of the groups you can still have the 1 fastes hourse and 2nd fastes from all 25 hourses, but by this method of elimination you have already decided that the secound fastes hourse is no longer competing and the 1st fastes hourse is compeeting to the once left from other groups.

    • @mitsuriKoi
      @mitsuriKoi 10 місяців тому

      Exactly. In some competitions, the best of the best go straight to the finals, but it does not mean the newcomers aren't stronger.

    • @dollhead
      @dollhead 9 місяців тому +5

      @@mitsuriKoi which is why the whole mechanical horse with a pre-designated time that always stays the same made this make a LOT more sense for me!!

  • @artempak3055
    @artempak3055 9 місяців тому +4

    It's actually 6, assuming that you don't need a universal algo to get the fastest 3, but looking for the way to get the absolute minimum races with your luck got tuned to the max. You have 5 random horses to race, pick the winner, then add another 4 and assume that you're lucky and your winner came 4th or 5th which guarantees that 3 fastest horses are not in the group 1. You repeat this 5 times with absolute "luck" where every time the winner from the previous group comes 4th or 5th and in the last group the first 3 would be the fastest horses

    • @yurenchu
      @yurenchu 9 місяців тому

      It's not 6, the "minimum" in the question clearly refers to the minimum across methods (i.e. the question asks for the most efficient method), not the minimum for a particular method, nor the minimum for a particular "best-case" scenario.
      Anyway, your approach always picks the winner of a race to race against four fresh horses in the next race. You will then identify the three fastest horses in 6 races if (and only if) the two fastest horses happen to be among the last four fresh horses; the 1st, 2nd and 3rd place finishers of race 6 can then be identified as the three fastest horses overall. (It's not necessary that the winner of a race finishes 4th or 5th in the next race; as long as the winner of race 5 doesn't finish 1st or 2nd place in race 6 , your method succeeds.) The probability of that scenario is 4/25 * 3/24 = 1/50 = 2% . In other words, the chance that you're lucky and will succeed to identify the three fastest horses in 6 races, is 2%, or one-in-fifty.
      That's not bad. However, this is not "your luck tuned to the max". Or more precisely, this is not the endpoint of "looking for the way to get the absolute minimum races with your luck got tuned to the max". There exists a method where the likelihood of identifying the three fastest horses in 6 races is much greater than 2% -- even greater than 20% (i.e. better than one-in-five). You may want to have a go and try to find such a "maximized luck" method (you're already close).

    • @wiseman513
      @wiseman513 6 місяців тому

      That's exactly my answer. Our strategy is probabilistic but it offers the true Absolute Minimal number of races. It's not optimal as it doesn't guarantee the final answer in the 6th race, but at least it offers the possibility of getting it by the 6th race. I love it.

    • @lacieemai6103
      @lacieemai6103 6 місяців тому +2

      lol, if you start using luck, why not to pick random 5 horses just once? If you're lucky enough, top-3 horses from these five will be the fastest across all of the horses. Yay, only 1 race needed if you're lucky!

    • @iskelet_mano
      @iskelet_mano Місяць тому

      ​@@lacieemai6103 or even pick 3 random horses with no race if you are "lucky" you chose the 3 fastest with 0 race thats even better lol

  • @rkidy
    @rkidy 15 днів тому

    Before watching this is what I came up with:
    Running a tournament where each race has 5 horses, you’d need 5 races to narrow down 5 winners and then a last race to determine the fastest. You’d then run this tournament again on the other 24 horses to get the second fastest and again on the other 23 to get the 3rd fastest. The first tournament requires 6 races. In the second tournament, the only new races is the one with the fastest horse removed in the first round, and the race of the winners. Applying similar logic to the 3rd tournament, each only requires 2 new races.
    Thus we can do 6+2+2 = 10 to get the 3 fastest horses.

  • @jakebarry8456
    @jakebarry8456 Рік тому +171

    I was originally going to ask why 6 wouldnt work, but the visuals really helped me find that out. Great video!

    • @jordantyler148
      @jordantyler148 Рік тому +13

      @@jasonbernard5468 it’s not a solution if it doesn’t work in all cases

    • @jasonbernard5468
      @jasonbernard5468 Рік тому +1

      @@jordantyler148 yea my ideaonly works in one case anyhow otherwise it needs 8. I was wrong when i commented before

    • @jasonbernard5468
      @jasonbernard5468 Рік тому +3

      @@jordantyler148 actually Im not sure, imight have been right, but not the way i thought. You say it isnt a solution unless it works in all cases, but what if i had a method that gives the answer in 6 rounds if and only if all top 3 horses are in the first group, and gives it in 7 rounds if not? Im not sure if I have such a method, but if I did it would be a better answer than the video, would it not?

    • @jordantyler148
      @jordantyler148 Рік тому

      @@jasonbernard5468 It would be interesting if you had a method that sometimes worked in 6 rounds, but occasionally needed an additional round, but only if you knew if it was done after 6 rounds, not if you do the 6 rounds and you dont know if its right.

    • @joshuafredrickson9719
      @joshuafredrickson9719 Рік тому +6

      ​@@jordantyler148 There is a method that works for all cases and in best case is only 6 races, but worst case 11. It does not involve doing 5 races with all horses like this. You do an initial race which gives you an initial #1, #2, #3. You take you 3rd place and race it against 4 new horses. If any are faster than current #3 then you race the fastest 3 of those against your current #1 and #2, giving you a new set of finishers. And continue with whatever the current #3 is. Best case, they are in order and you do 1 initial race plus 5 additionals where none are faster that that first #3, so 6 total races. Worst case they are in reverse order. and you will have to re-race after each of the 5 races, so 11 max. The question is to find the minimum, not the most optimal solution. So this would be a "better" answer.

  • @pa_3op
    @pa_3op Рік тому +68

    This was actually a pretty good case of problem where you can start from easier examples to get the solution. I took «fastest 2 of 4 with 2 racing at a time» and «fastest 3 of 9 with 3 racing at a time» which brought me to idea of elimination in no time.

    • @yurenchu
      @yurenchu 11 місяців тому

      What was your optimal method for "fastest 2 of 4 with 2 racing at a time"?
      And for "fastest 3 of 9 with 3 racing at a time"?

  • @foxycritter
    @foxycritter 6 місяців тому +12

    I always got confused by this until it was described as mechanical horses with set finish times. I usually thought of all of the different factors that were unknown, such as age, track conditions, how healthy each horse was, behavioral issues, etc

    • @Alpha_Online
      @Alpha_Online 5 місяців тому

      Always remember that in such questions only the information given to you exists, nothing else does.

  • @SirRebrl
    @SirRebrl 9 місяців тому +1

    So close! I got 9, because I didn't think of rearranging the groups by the 6th race results and so I did 3 races in that step. I ended up with the same last race anyway, so right technique, just a couple superfluous races in there.

  • @Sachin1197
    @Sachin1197 5 років тому +637

    I paused and played the video only after solving the problem, now most important question is how much time does Google give in interview? 😁

    • @writer_gupta_ji
      @writer_gupta_ji 3 роки тому +32

      2 minutes only

    • @ianarchibald7928
      @ianarchibald7928 3 роки тому +11

      @@writer_gupta_ji wow, that is really hard

    • @nothingnothing1799
      @nothingnothing1799 3 роки тому +30

      @@writer_gupta_ji*(edit this method is flawed as pointed out by others below me)*
      I solved it in less then 2 minutes, tho I solved for 6-7 (ill explain that later) using a different method which is race 5 horses then race first place against 4 new repeat 5 times keeping track of the second place horses at the end of the sixth race if the fastest horse of race 5 isn't first or second then the top 3 are the 3 fastest else race 2nd place horse of race 5 against 3rd place of race 6 and first place of race 7 is 3rd fastest. This is a better solution because there is an 84.43% chance u will only need 6 races. *>>> AGAIN THIS METHOD IS FLAWED SO PLZ STOP COMMENTING THAT IM WRONG, I AM WELL AWARE.

    • @SaifKhan02804
      @SaifKhan02804 3 роки тому +9

      i even solve this question only reading at thumbnail and then open video 😅

    • @23kaushikdutta
      @23kaushikdutta 3 роки тому +47

      @@nothingnothing1799 Maybe I am missing something, but how does your method work? Imagine if your very first race had all three fastest horses in it, and you basically eliminate the 2nd and 3rd fastest ones at the very beginning, and never return to them in your procedure above, how do you get to the top three?

  • @E7visuals
    @E7visuals 2 роки тому +267

    Better solution : sell all the horses and buy a motorcycle if you need speed.
    Edit : dont forget to buy a watch if you don't have one

    • @BabyIshii
      @BabyIshii 2 роки тому +2

      What u gonaa do with speed and time when u don't have brain

    • @E7visuals
      @E7visuals 2 роки тому +14

      @@BabyIshii i have a brain which can atleast understand a joke which u couldn't. 🤦

    • @BabyIshii
      @BabyIshii 2 роки тому

      @@E7visuals ohhh my bad...I didn't know ur sense of humor died as well

    • @CzrPap
      @CzrPap 2 роки тому

      that's what how you solve the problem after you get the job. *because Google $$$$$

    • @ColonelSandersLite
      @ColonelSandersLite 2 роки тому

      I'm genuinely curious what percentage of people still have watches. They seem kind of redundant now TBH. Edit - and by have I mean "actually wear and use". Buried in the couch or the back of a junk drawer isn't what I'm talking about.

  • @songwill9017
    @songwill9017 11 місяців тому +2

    Thought about 8 races at the very beginning, which step 1 and 2 are the same, step 3 would be changing a2 for a1 and race again, and swap the fastest in this group with the second fastest in his original group to race again. Then I realize that some horses has been racing too many times but not giving me enough information. So I knew 8 is not the most efficient way to do it. I thought really hard and got the right answer.

  • @junaidywijaya6413
    @junaidywijaya6413 8 місяців тому

    I know this old, ask to youtube, but it's a really good video and perfect explanation as well

  • @MrGunsnrosesfan100
    @MrGunsnrosesfan100 2 роки тому +470

    My solution was to grab 5 horses, race them, put the slowest two aside and grab two more to race off against the fastest 3 so far identified, after this race, the losers will be put aside and two new horses will face off against the fastest three from the second race, etc.
    Not particularly quick, but since the horses won't get tired, you will eventually end up with the three fastest horses

    • @haydenhuss8758
      @haydenhuss8758 2 роки тому +53

      that's the solution i got. it's only 4 races more than needed, so I'm still proud of myself for coming up with that solution.

    • @fayt9121
      @fayt9121 2 роки тому +5

      @@haydenhuss8758 you just do sets of five and then race the winners of each set for a total of 6 races.

    • @fayt9121
      @fayt9121 2 роки тому +4

      this works because each horse will be equally as tired since each horse will have had one race.

    • @Macarthurmaintenance
      @Macarthurmaintenance 2 роки тому +83

      @@fayt9121 that doesn’t work. Lets say the second fastest horse was in the same heat as the fastest horse of all 25 horses. Then the second fastest horse would never be included in your final (6th) run.

    • @fayt9121
      @fayt9121 2 роки тому +1

      ​@@Macarthurmaintenance this is true. so you are saying you have to race a total of 8 times since you want the 3 fastest horses right? you do your first six to find which one is the fastest and then you race second and third place against the winners from groups 2-5. I get that. And with this hypothetical, its possible that the horses don't get tired either. Ill be honest I cant put my finger on it but something's bothering me about this.

  • @tasmeena
    @tasmeena 5 років тому +48

    Oh wow! I actually got this right. I almost never get any of your puzzles right so I’m beyond thrilled! Love your channel!

  • @samwhite4961
    @samwhite4961 10 місяців тому +2

    You should stipulate the minimum races that *guarantees* you find the 3 fastest horses. Otherwise the answer is 6 if your lucky and found the three fastest in your first race. 1 race the find the 3 fastest and 5 races to test your third fastest against all others.

  • @Vescense
    @Vescense 4 місяці тому

    You can do it in 6. If at each race, you mark in the dirt where the other horses were when the 1st place finished. You can use these marks in the sand as a pseudo "clock", by using the ratio of the differences in distance compared to the total track. It should take 6 races if done correctly

  • @MindYourDecisions
    @MindYourDecisions  5 років тому +2212

    2 million views! Thank you!

    • @MrPeloseco
      @MrPeloseco 5 років тому +6

      Thank you!!

    • @jayant9151
      @jayant9151 5 років тому +9

      Can you please change your theme to a black board
      Thankyou

    • @mohtaw3680
      @mohtaw3680 5 років тому +64

      What if the 5 horses in group "a" were actually faster than all other horses ... How you will solve it without a watch

    • @Natertot.
      @Natertot. 5 років тому +1

      I guessed 7 does that count

    • @yurenchu
      @yurenchu 5 років тому +19

      @Moh Taw,
      - "What if the 5 horses in group "a" were actually faster than all other horses ... How you will solve it without a watch"
      That's exactly why horses a2 and a3 also participate in the seventh race (along with b1, b2 and c1), which they will win in your scenario.

  • @lukeh7854
    @lukeh7854 3 роки тому +158

    As a project manager: “Build a stopwatch then we can time the horses”.

    • @davidhawley1132
      @davidhawley1132 2 роки тому +1

      Doesn't work in scenarios where a stopwatch can't exist, e.g. in distributed systems. Ref Logical Clocks, from the 1970s.

    • @lukeh7854
      @lukeh7854 2 роки тому +13

      @@davidhawley1132 ok thanks David. I’ve noted your assumptions. I’ll speak to the client in relation to your concerns of legacy constraints and find out if these are going to be problematic... I have liased with them and it turns out that we live in 2021 and we’re dealing with a startup. It’s also apparent that there are already timing tools available on the market, so I’ve conducted build vs buy analysis and it makes sense to procure the stop watch instead. $3 from Amazon. Since finding the fastest horse is going to be repetitive it also means we can make huge time savings in efficiency across the product life cycle and there is less risk involving the horses. So I’m grateful for your input as this led to a cost saving of tens of thousands. I’m giving you a pay rise and I’ll write a case study based on your input for lessons learned in the next knowledge sharing workshop so we can all benefit from your unrivalled wisdom.
      Lol obviously this was not a serious solution dude.

    • @davidhawley1132
      @davidhawley1132 2 роки тому

      @@lukeh7854 Code bootcamp grads would try to pull the move you suggest. My Comp Sci degree was in the Math dept, and we studied problems like this.

    • @xnadave
      @xnadave 2 роки тому

      @@davidhawley1132 We have "stopwatches" that work just fine in distributed simulations. It's a very difficult problem with an embarrassingly simple solution. (But, I'm also talking software - getting circuits in time without a common clock is something I'm not going to mess with, unless performance is not a concern.) (And who wants to work on something where performance is not a concern?) :D

    • @davidhawley1132
      @davidhawley1132 2 роки тому +1

      @@xnadave It's a classic problem with a good-enough solution. But from the comments, I bet few posting here even know there is a problem.

  • @thereisnoname1
    @thereisnoname1 4 місяці тому +1

    the thing is ... after 1 minute of seeing the puzzle i assumed its gonna be 6 . but i felt its a too easy answer to make a video about , so i stood for a WHILE trying to get a number below 6 . i dont know why i though it must be lower than mine

  • @ZodiusXx
    @ZodiusXx 11 місяців тому

    I did the 5/25 thing and then figured you'd need 2 more after to test the winners.

  • @pjohnjay12
    @pjohnjay12 5 років тому +151

    It would have a lot of pressure since it’s asked during an interview

    • @samwhaleIV
      @samwhaleIV 5 років тому +29

      And that's when you pull out your horses

    • @elladan23
      @elladan23 5 років тому +10

      I suppose that's the point in the interview more than any other thing.

  • @boncawillywonka8626
    @boncawillywonka8626 2 роки тому +58

    The smartest person seems to be the person who comes up with the question with the answer in mind. Honestly takes a lot of brain power to come up with a problem and solution a lot of people cant solve

    • @commandercaptain4664
      @commandercaptain4664 2 роки тому +4

      @@Naughty_Squad Which is why mathematics and linguistics are bad bedfellows.

    • @ollie2891
      @ollie2891 2 роки тому

      @@Naughty_Squad I disagree, the problem itself is very simplistic and makes sense what is being asked. All you need is logic.

    • @hut6815
      @hut6815 2 роки тому

      @@commandercaptain4664 Strange bad fellows

  • @ethangrieshop9405
    @ethangrieshop9405 11 місяців тому +16

    My guess before watching the video: 7 races. Do five races to make sure you’ve seen all 25 horses race. Then you only race the winners of every race against each other. The horses that came 4th and 5th can be eliminated in addition to the horses that came behind them in the first race. Also, the horses that came second and third against the horse who came third in the second race can be eliminated as well as the horse that came third in the race against the horse who came second in the final race. This leaves us with six horses. We already know that the horse that came first in the final race is the fastest horse overall so we don’t have to race it. We just race the remaining 5 to get the top two from there and those become second and third overall.

  • @element1192
    @element1192 8 місяців тому +1

    The real question is how we can generalize this to a function horse_race(total, race_capacity, podium) == minimum_races where total > 0, race_capacity > 1
    if total == race_capacity, then minimum_races == 1
    if podium == 1, then minimum_races == total / race_capacity

  • @JianJiaHe
    @JianJiaHe 7 років тому +690

    How about n horses? And we are only allowed m horses in each race. Is there a general formula for this?

    • @Scorpionwacom
      @Scorpionwacom 7 років тому +55

      Great question! Thumbs up, so Presh can notice it.

    • @oldcowbb
      @oldcowbb 7 років тому +65

      and we need to find the top x horse

    • @codebeard
      @codebeard 7 років тому +31

      I'm not sure about all combinations of numbers of horses etc, but the method in the video works for ¼(k-1)²(k+2)² horses where you can race ½(k-1)(k+2) horses in each race.

    • @BigDBrian
      @BigDBrian 7 років тому +31

      I think it's more adequately written as (½(k-1)(k+2))² horses and ½(k-1)(k+2) horses per race.
      That makes it more obvious the former is the square of the latter.

    • @stevethecatcouch6532
      @stevethecatcouch6532 7 років тому +2

      +codebeard Is k the number of horses we're trying to find, or is it just a coincidence that k=3 for 25 horses? If k is the number of horse we're trying to find, the minimum number of races is ½(k-1)(k+2) + 2.

  • @glutinousmaximus
    @glutinousmaximus 7 років тому +469

    The answer is ZERO races! Just kill any 22 horses (the stated rules do not preclude this option) The remainder will always be the 3 fastest horses.

    • @cjzojan3166
      @cjzojan3166 7 років тому +6

      Adam Mangler But you still wouldn't know which of them is the fastest

    • @glutinousmaximus
      @glutinousmaximus 7 років тому +5

      Of course you would - (of the survivors anyway!)
      *_:0)_*

    • @forestwow1487
      @forestwow1487 7 років тому +3

      Adam Mangler you just killed your top 3 fastest horses and spared the slowest of em all... you never know :p

    • @hunterbradshaw1995
      @hunterbradshaw1995 7 років тому +20

      forest wow He's saying that if they're are only 3 horses left then they have to be the fastest three horses because all the other horses are dead.

    • @andychauhan6544
      @andychauhan6544 7 років тому +8

      Adam Mangler...you get the top prize for thinking outside the box...also for being a leader among the ratards :-)

  • @andregregio
    @andregregio 8 місяців тому

    Nice one. Got it in 8 races, and then in 7 when i read that you are supposed to remove the horses that are guaranteed to be slower

  • @13thArkangel
    @13thArkangel 11 місяців тому

    Correct me if I'm wrong, but the way that this question is stated, it is not necessarily asking for the minimum number of races to identify the three fastest horses every time, but can be interpreted as just the minimum number of races to identify the fastest ones at all.
    Suppose you pick the three fastest horses in the first race already, that leaves 20 horses unknown to you. If now you pick the third horse from the first race and paur it off against four of the remaining horses, each race would identify four additional horses as slower than the third horse from the first race. This method requires five races to rule out the remaining 20 horses in addition to the first race, thus requiring only six races - under the assumption that you hit the special case where you pick the correct horses in the first race by chance. Again, not guaranteed to work, but technically less than seven given the wording of the question.

  • @alexnezhynsky9707
    @alexnezhynsky9707 4 роки тому +47

    If you ever end up with 25 horses and you forget their speed, not that you ever will but still, well, now you know...

    • @absolstoryoffiction6615
      @absolstoryoffiction6615 3 роки тому +3

      It's a logical problem with practical labeling. It's not that difficult, really.

    • @achtsekundenfurz7876
      @achtsekundenfurz7876 3 роки тому

      Exactly. It's an IRL variant of sorting algorithms which only go by relation (more, less, equal) of the input data, this time a variant which takes 5 inputs, and outputs relations of every pair within those. It's less relevant IRL now, but might have been very relevant before you could time the races.
      Thinking about these problems becomes easier if you visualize the ranking of a horse as the # of horses it would lose against, making rank 0 the fastest. Sometimes, ties tend to mess things up, but in this case, they don't.

  • @HumanInterests
    @HumanInterests 3 роки тому +547

    If you’re lucky enough to choose the top three in your first race then it can be done in a minimum of 6. Race third place against every remaining horse (choose 4 horses + 3rd place and run 5 times), if it wins each race you know the original top 3 were fastest. Only works 0.06% of the time though.

    • @violetstetpedder-4824
      @violetstetpedder-4824 3 роки тому +35

      The third fastest could also be in the last group. If the 3rd horse comes 2nd in the last race then you know the three fastest are the first 2 from the first race and the first from the last race.

    • @Elanochecer92
      @Elanochecer92 3 роки тому +19

      This is the "solution" i reached too

    • @aeginavincy1890
      @aeginavincy1890 3 роки тому +19

      The problem is when your third fastes horse was last place in next group, but yeah 6 is probably still the minimum number

    • @violetstetpedder-4824
      @violetstetpedder-4824 3 роки тому

      @@aeginavincy1890 There's no problem.

    • @aeginavincy1890
      @aeginavincy1890 3 роки тому +4

      @@violetstetpedder-4824 So what are you gonna do if your third fastest got last in next group?

  • @paweborkowski6959
    @paweborkowski6959 8 місяців тому

    Elegant illustration.

  • @eodzo
    @eodzo 8 місяців тому +1

    I said 7 off the top with pausing my reasoning for this is that after you watched all horses you race the top 5 against each other to find first. then you take second place and third place of that race then put 2nd and 3rd an 4th from the 1st place horse original group to have five. too find the 2nd and third place, we know 2nd group and below have Guaranteed slower horses from looking at top 5 so all you gotta do is take that line up of( top 5 2nd and 3rd )then (winning horses starting group, 3rd and 4th )

  • @grapeicies
    @grapeicies Рік тому +47

    I got 8 because I didn’t think to rearrange the groups based on the results of the 6th race. I was adding an additional step where all the 2nd place horses from each group raced but it was basically an inefficient way to get the same result that you’d get in the 7th race in this solution.

    • @codrincx
      @codrincx Рік тому +3

      Had the exact same thought process, but a total eureka as soon as the video said "we split them into groups" and I went "OH WAIT WAIT WAIT IS SEE IT no point in racing the nr 4 and 5 horses from the winner race, that frees up 2 more slots!"

    • @JaxonHaxon
      @JaxonHaxon Рік тому

      @@codrincx same and i got stuck on how to fit a3 in there cos what if all 3 fastest horses were in the same race, you dont need to race the fastest again freeing up another slot *d'oh* 🤦‍♂🤦‍♂🤦‍♂

    • @ucthebadvc134
      @ucthebadvc134 Рік тому

      me neither!

    • @onepun9583
      @onepun9583 Рік тому

      @@codrincx i have a question: at this part 7:40, what if e2 < d2 < b2 < c2 < c1 < b1? And what if b2 < c2 < d2 < e2 < e1 < d1 < c1 < b1?

    • @codrincx
      @codrincx Рік тому +1

      @@onepun9583 If I'm understanding your comment right, then:
      The d and e group cannot imaginably matter, since after the first races, we know for sure that a1 > b1 > c1. Therefore, any horse from group e will be slower than *both* b1 and c1. The only horses that could be faster than b1 come from group a (as all horses in group c, d and e are all slower than b1), and then the only horses that could be faster than c1 come from groups a and b.
      Notice that in both scenarios you've written, b1 and c1 are the fastest, therefore the only ones actually relevant. If a2 or a3 (could also be a4 or a5, but we only care about top 3) isn't faster than b1, then b1 *is* the 2nd fastest horse. Similarly if b2 isn't faster than c1, then c1 *is* the 3rd fastest horse.

  • @LongPham-jg3ty
    @LongPham-jg3ty 6 років тому +887

    To the people saying 6 is the answer
    What if the 3 fastest horses are placed in the same group by chance
    Do you get why there are 7 race needed now?

    • @Simon_Reeves
      @Simon_Reeves 6 років тому +28

      If so why removing group e and d would be correct since you dont have a watxh

    • @LongPham-jg3ty
      @LongPham-jg3ty 6 років тому +42

      Simon REEVES after racing the 5 fastest horses from each group you can automatically eliminate these 2

    • @Frikgeek
      @Frikgeek 6 років тому +55

      Because every horse in group D or E is by definition slower than top C which is AT BEST the third fastest(top B and top A beat it in a race). So at best every horse in D and E can be fourth fastest and can therefore be eliminated.

    • @PhuckEwerself
      @PhuckEwerself 6 років тому +14

      So if following this example the times for slowest to fastest in each group are as follows:
      A: 10, 9, 8, 7, 6
      B: 14, 13, 12, 11, 10
      C: 15, 14, 13, 12, 11
      D: 16, 15, 14, 13, 12
      E: 17, 16, 15, 14, 13
      How is it valid to eliminate a3-a5 as being slower than b1?

    • @Frikgeek
      @Frikgeek 6 років тому +36

      You're not eliminating A3, you're eliminating A4-A5, B3-B5, C2-C5, all of D and all of E. Which will always be valid. You're not eliminating them for being slower than B1, you're eliminating them for being slower than AT LEAST 3 other horses. The final race is A3, A2, B1, B2, and C1 since those are the only horses left that aren't confirmed to be slower than at least 3 others.

  • @rlton
    @rlton 11 місяців тому

    Looks like I won't be working at Google, you gave the solution and I still got confused 🤣

  • @lucaspfeifer4529
    @lucaspfeifer4529 11 місяців тому +2

    Here's a way it could be done in 6, but it requires that the top three are in the first group. Step one: race the first group. Step two: do 5 races with the third place horse and 4 new horses. If the top three are in the first group, the third horse will win all of the next 5 races.

    • @p0lise
      @p0lise 7 місяців тому

      Came up with the same solution. Chances are small that the first race will indeed have contained the overall top three, but yeah, it's a minimum of six races.

  • @Scorpion1995100
    @Scorpion1995100 Рік тому +65

    my first idea was like " well, you need atleast 6" but seeing how you solved it, makes total sense. thank you for enlightment!

    • @westofley
      @westofley Рік тому +4

      I knew it was at least 6 to find the fastest, and I was sure that there was a way to do a seventh where you get the 2nd and 3rd, so the right answer was _probably_ 7. I didn't reason out the exact way to _do_ the 7th race, but I didn't need to bc I knew it was possible. I don't know how some people got 11 or 12

    • @Kylec0pezTR
      @Kylec0pezTR Рік тому +2

      @@westofley 11 comes from racing 5 horses, then removing the 2 slowest and inserting 2 others until you have only the last 5 horses in which case the top 3 are the fastest 3 overall. You need to drop 22 horses in total, 2 horses per race means 11 races using this strategy.

    • @vishulangeh8348
      @vishulangeh8348 11 місяців тому +2

      ​@Wesley Pardo I still think it's 6 races total, 5 races to get top 5 from lot of 25 and from that lot of 5 you'll get 1st, 2nd and 3rd as it's mentioned in question that you'll get " printout with the order the horses finished" so that'll be the fastest three in the order provided in the printout.

    • @yerpderp6800
      @yerpderp6800 11 місяців тому +7

      ​@@vishulangeh8348 you don't know relative times so it's possible the horses that came in second and third for the first race are faster than all of the horses in other races. Assuming the second and third horses in the 6th race are faster than those horses from the first race is unjustified

  • @1Beetlegeuse
    @1Beetlegeuse 2 роки тому +231

    My first idea was taking the 2 slowest off each time as well. Ended up with 11 races however I appreciate it can be done in less.
    But upon further contemplation I figured if I'm at Google I'd just pick 3 random horses. The truth is what we say it is.

    • @jenswurm
      @jenswurm 2 роки тому +12

      Same idea here. A way with less races may possibly exist, but designing and verifying its veracity likely takes longer than the few races that it might save us, so we better simply get those horses to run.
      One could ask the interviewer, "is the question here really about the best algorithm, or is it about figuring out which are the three fastest horses in the most efficient way?"

    • @crashoverwrite5196
      @crashoverwrite5196 2 роки тому +16

      yes man. you got it with 11.
      The problem is that you dont have a time/ watch nor a distance! If you let 5 groups run, and you take the 1st. of each group, you can not be sure if these horses are one of the fastest 3. 1st horse in group (a) maybe can run just 2Kmh and the 1st of group (c) can run 40kmh while 2nd of group (E) can run 60 kmh! . you have to have a constant to really get the 3 fastest! My logic: So you let the first 5 race, then you let the first second and third place on the track and get 2 new ones in, every race the 4,5 will be replaced. with this method you have always a constant for first, second and third place without needing a watch ! each race, 11 in total , will naturaly eliminate 4 and 5 place ! imagine this: lets say the first group are the 5 slowest of all, so the slowest up to the 5th slowest of all. in the second race the 4th and 5th place gets replaced with (in this simplyfiyed case)faster ones, and maybe one is the fastest of all and the other one the 2nd fastest of all. they will be 1st and 2nd place of the 2nd race and they will stay on this position. the 3th will be found after all other races are finished. You can switch the start situation, that the first 5er group have two of the fastest of all in it, so the first and second place will be set after the first race, and again the other races and just to find the real 3th place.---- i think its 11 races ! 😃

    • @johns9652
      @johns9652 2 роки тому +3

      I started out saying 10, then realized I could eliminate the 4th and 5th place horses from the first 5 races. Just as I was patting myself on the back and saying the answer was 8 races, the rest of the video played. Guess I'm not as smart as I thought I was.

    • @wolfrainexxx
      @wolfrainexxx 2 роки тому +2

      @@johns9652 6 races, because reality isn't so comfortable; you have the winners run, and the winner of winners is the fastest with 2nd & 3rd place marked behind it.
      If UFC, or other events operated like y'all are suggesting, then all competition sports should be eliminated, and all champions should return their trophies.

    • @nobodyknows3180
      @nobodyknows3180 2 роки тому

      I used that approach initially. 25 horses to start, 5 races, two slowest eliminated each race, 15 horses left. 3 races, two slowest eliminated each race, 9 horses left. 2 races, but with nine horses, you'll have one group of five and one group of four, and you need to keep the fastest three from each group, so eliminate the two slowest from the group of five, but only one from the group of four. This creates somewhat of a dilemma, as you have already run 10 races and you still have 6 horses.
      Run a race of five, with the sixth sitting out. Knock out the two slowest from that group, leaving the three fastest and with the one that sat out, that's four remaining. That was 11 races so far
      The final race will show who is 1-2-3 out of the original 25. But that was 12 races.

  • @johnd3293
    @johnd3293 11 місяців тому

    for folks not understanding why the above question is considered a "trick" and a logic puzzle (which is quite a few given the discussions in the comments) the reason is because there are two correct answers depending on how you interpret the nebulous statement "minimum number of races needed". If you interpret that statement as "the minimum number of races possible that could answer the question" the answer is 6 races. if you interpret the statement as "the minimum number of races that will definitely provide an answer" the answer is 7.
    For the first version, if you race the first 5 horses, then take the 3rd fastest from the first group and put it in a group with the next 4, and repeat this for the rest of the horses, it could take you as many as 12 races to determine the 3 fastest. OR if you are lucky and the 3rd fastest horse from group 1 wins every other race it takes you as few as 6 races. Hence the minimum possible.
    For the second version, you can follow @OP 's method which gets you to 7, the minimum number of races that guarantee you to know the top 3 horses.
    it just depends on how you interpret the question statement, which is intentionally vague (even with OPs additional detail.)

  • @arimil.
    @arimil. 9 місяців тому

    I just kept doing races of 5 and eliminating the two slowest, not doing a race when a group fell below 5. This leads you to an answer of 11.
    25 (5 races) -> 15 (3 races) -> 9 (1 race) -> 7 (1 race) -> 5 (1 race).