The ultimate tower of Hanoi algorithm

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 มิ.ย. 2024
  • There must be millions of people who have heard of the Tower of Hanoi puzzle and the simple algorithm that generates the simplest solution. But what happens when you are playing the game not with three pegs, as in the original puzzle, but with 4, 5, 6 etc. pegs? Hardly anybody seems to know that there are also really really beautiful solutions which are believed to be optimal but whose optimality has only been proved for four pegs. Even less people know that you can boil down all these optimal solutions into simple no-brainer recipes that allow you to effortless execute these solutions from scratch. Clearly a job for the Mathologer. Get ready to dazzle your computer science friends :)
    I also talk about 466/885, the Power of Hanoi constant and a number of other Hanoi facts off the beaten track. And the whole thing has a Dr Who hook which is also very cute.
    00:00 Intro
    01:58 Chapter 1: The doctor vs. the toymaker
    14:27 Chapter 2: Hanoi constant
    21:21 Chapter 3: The Reve's puzzle
    28:04 A beautiful shortest solution for 10 discs and 4 pegs (discs and super-disks)
    30:23 Chapter 4: Unprovable algorithm
    35:43 A beautiful shortest solution for 10 discs and 5 pegs (discs, super-discs and super-super-discs)
    37:17 Supporters
    Here are some references for you to check out:
    Andreas M. Hinz et al. - The Tower of Hanoi - Myths and Maths, 2nd edition (2018, Birkhäuser Basel) That's the book I mentioned in the video.
    The Dr Who episode (well the part that's not been lost) www.dailymotion.com/video/x11...
    The 3Blue1Brown video that I mention • Binary, Hanoi and Sier...
    Thierry Bousch, La quatrième tour de Hanoi, tinyurl.com/4p3fudu7
    That's the paper that pins down things for four pegs.
    Andreas M. Hinz, Dudeney and Frame-Stewart Numbers,
    A nice paper explaining the connection between Dudeneys's work and Frame-Stewart. Also worth reading for the historical details. tinyurl.com/t8xb2e5t
    A. van de Liefvoort, An Iterative Algorithm for the Reve's Puzzle, tinyurl.com/h5cxfy5u
    I found this one useful.
    Paul K. Stockmeyer, www.cs.wm.edu/~pkstoc/toh.html A couple of very nice papers including a huge bibliography.
    Ben Houston & Hassan Masum, Explorations in 4-peg Tower of Hanoi, tinyurl.com/mw95tnek This paper has some pictures of state graphs for the 4-peg puzzle.
    towersofhanoi.info/Animate.aspx Very fancy animation of mulit-peg tower of Hanoi. Sadly, it just comes across as a mess of moves for more than three pegs. Programmers, you really should rise to my challenge to animate the 4-peg algorithm the way I present it in this video.
    Here is the link to the wiki page for the Celestial toymaker Dr Who episode en.wikipedia.org/wiki/The_Cel...
    Makes very interesting reading. Especially the fact that most of this episode has been lost I find pretty amazing. That's also why I only show a still image from the relevant part of the episode and play some audio snippet.
    Music: Fresh Fallen Snow and Morning Mandolin both by Chris Haugen, Mumbai effect. All from the free TH-cam audio library.
    Enjoy!
    Burkard

ความคิดเห็น • 833

  • @Nikolas_Davis
    @Nikolas_Davis 3 ปีที่แล้ว +709

    "If you're ever captured by an evil toymaker, you'll be ready"
    And they say math has no real-world applications.

    • @farrankhawaja9856
      @farrankhawaja9856 3 ปีที่แล้ว +7

      Underrated comment :)

    • @warrenbosch3581
      @warrenbosch3581 3 ปีที่แล้ว +1

      Very cool!

    • @Shadow-xb2ce
      @Shadow-xb2ce 3 ปีที่แล้ว +6

      I much prefer an evil toymaker to the "motorcycle mathematicians" my sarcastic (as I was told) Calc II teacher used to love throwing us.

    • @orstorzsok6708
      @orstorzsok6708 3 ปีที่แล้ว +1

      :D :D :D

    • @titaniumtomato7247
      @titaniumtomato7247 3 ปีที่แล้ว +1

      @@Shadow-xb2ce ?

  • @outputcoupler7819
    @outputcoupler7819 3 ปีที่แล้ว +139

    That's it, I'm stealing that. I'm no longer a Software Engineer, I'm an Algorithmologist.

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +20

      Let's hope this word catches on :)

  • @citolero
    @citolero 3 ปีที่แล้ว +235

    17:40 "This recipe also solves another Hanoish puzzle." I think the correct adjective is "Hannoying".

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +28

      :)

    • @StefanReich
      @StefanReich 3 ปีที่แล้ว +8

      Hanoisy

    • @nickbradley8354
      @nickbradley8354 3 ปีที่แล้ว +2

      So Hanoid! Saigonna say that. Halong ago you see this? Gotta be quicker next Thai.

    • @leif1075
      @leif1075 3 ปีที่แล้ว

      @@Mathologer Did you really learn the towers of Hanoi in primary school?? I hope you can PLEASE respond.

    • @NStripleseven
      @NStripleseven 3 ปีที่แล้ว

      Hahaha

  • @Mathologer
    @Mathologer  3 ปีที่แล้ว +281

    There must be millions of people who have heard of the Tower of Hanoi puzzle and the simple algorithm that generates the simplest solution. But what happens when you are playing the game not with three pegs, as in the original puzzle, but with 4, 5, 6 etc. pegs? Hardly anybody seems to know that there are also really really beautiful solutions which are believed to be optimal but whose optimality has only been proved for four pegs. Even less people know that you can boil down all these optimal solutions into simple no-brainer recipes that allow you to effortless execute these solutions from scratch. Clearly a job for the Mathologer. Enjoy :)

    • @superman00001
      @superman00001 3 ปีที่แล้ว +8

      Hello Mathologer - there is a nice (possibly related, to an extent) puzzle that asks how many different unique ways a spider can put on his shoes and socks, given that each foot must receive a sock followed by a shoe. Can you solve it? (I did, and it’s a nice solution!).

    • @tcadityaa
      @tcadityaa 3 ปีที่แล้ว +3

      Good evening Mr Bukard, I have something to share with you. Our Biology teacher(yes! Our Biology teacher!) told us about an approximation relating Pythagorean triplets. I ran it on Python and its accuracy(in terms of how good the approximation is, or in other words how consistenly low the error percentage is) is very good, though its accuracy rate decreases as we crank up the size. Should we discuss it further here sir? Or how shall i contact you. Because Sir, I assure you, this is not some attention seeking stunt. I trued so hard to figure it out but the 100% accuracy numbers just pop up randomly...I have no idea....

    • @ChefSalad
      @ChefSalad 3 ปีที่แล้ว

      You should get yourself a :CueCat as a technological mascot to go with your website. The best part is that it's cat-shaped. It might even still work, if you can find a computer with a PS/2 keyboard port to use it with.

    • @johnchessant3012
      @johnchessant3012 3 ปีที่แล้ว +2

      Is it just me or is it very easy to read this paragraph in Mathologer's voice? :)

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +4

      @@superman00001 Ah, that's a nice one. Had not heard of this one before :)

  • @henridelagardere264
    @henridelagardere264 3 ปีที่แล้ว +265

    40 minutes of Professor Polster + links to 400 hours of reading = 1 helluva education
    Every single time, thank you for all you're doing, Mathologer!

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +31

      Enjoy :)

    • @andrewmartin3671
      @andrewmartin3671 3 ปีที่แล้ว +2

      Hear!

    • @SaveSoilSaveSoil
      @SaveSoilSaveSoil 3 ปีที่แล้ว +3

      I know right? I LOVE the references in the description of Mathologer videos

    • @l00d3r
      @l00d3r 3 ปีที่แล้ว +2

      I guess it is a BYOW (bring your own wine) party

  • @ajhokie130
    @ajhokie130 3 ปีที่แล้ว +105

    Don't let other TH-camrs doing the same topics stop you. Please! I like to see different takes on the same topic from my favorite TH-camrs.

  • @johnchessant3012
    @johnchessant3012 3 ปีที่แล้ว +51

    13:27 In 1,023 moves, moving the smallest disc every other move means we're moving it 512 times, which is 2 (mod 3). So we need to move it counter-clockwise (A -> C -> B -> A) to make sure it ends at B.
    In general, 2^(n-1) is 1 (mod 3) if n is odd and 2 (mod 3) if n is even, so we should move the smallest disc clockwise if n is odd and counter-clockwise if n is even.

    • @zanti4132
      @zanti4132 3 ปีที่แล้ว +8

      As the idea of clockwise vs counterclockwise isn't clear if the three pegs are in a straight line, I think it's easier to remember (a) if n is odd, first move the small disk to the peg that will hold the ending stack (b) if n is even, first move the small disk to the peg that will not hold the ending stack. Then build the smaller towers by alternating between the two pegs until you can move the largest disk to the peg that will hold the ending stack. This essentially reduces the puzzle to solving the tower with n-1 disks. Keep going like this until you are done.

    • @johannesh7610
      @johannesh7610 3 ปีที่แล้ว +6

      I thought about it with the recursion: upper ten to B requires upper nine to C, which requires upper eight to B, 7 to C, 6 B, 5 C,...

    • @Paul_Hanson
      @Paul_Hanson 3 ปีที่แล้ว +4

      @@zanti4132 In that case, instead of clockwise vs. counter-clockwise it's left and right. And here we hark back to the old video games where if you moved off the right side of the screen, you reappeared on the left side of the screen.

    • @DerKiesch
      @DerKiesch 3 ปีที่แล้ว +4

      @@zanti4132 I personally would find it easier to remember:
      1. Odd and even n need a different starting move to end up in the right spot.
      2. You check where you end up for the smallest odd stack (1 --> which is only one move).
      3. If you have an odd n, it's the same move as in 2, if even n, it's the "opposite" move to 2.
      4. After that you just continue moving the small piece in the same "direction" (clockwise / counterclockwise or left/right).
      Thats an easy way to convince yourself that you have the right direction

    • @PC_Simo
      @PC_Simo ปีที่แล้ว +2

      @@DerKiesch I agree about that being the easiest way to remember this 👍🏻.

  • @deffinatalee7699
    @deffinatalee7699 3 ปีที่แล้ว +34

    23:33 there’s another lovely pattern that’s easy to miss in this table; look at the antidiagonals. See anything familiar?

  • @rayhanmansoor2951
    @rayhanmansoor2951 3 ปีที่แล้ว +70

    So happy to see a new video. I was really upset when you didn't upload in February.

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +37

      Yes, sadly insanely busy at uni at the moment. COVID is still messing things up in a big way for us and so hardly any time for Mathologer :(

    • @niladriroy7650
      @niladriroy7650 3 ปีที่แล้ว +7

      @@Mathologer 😢

    • @nonachyourbusiness1164
      @nonachyourbusiness1164 3 ปีที่แล้ว +2

      @@Mathologer How is it affecting you guys? My uni is completely remote now and emphasis has been put on self-study

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +16

      @@nonachyourbusiness1164 Well in Australia we seem to have COVID pretty much under control with no new cases out in the open for a month. This means that life is pretty much back to normal, except it isn't. My uni tries to be as much as possible back to face-to-face. Sounds good but is incredibly messy with the government still requiring social distancing which results in all venues only being at half or less capacity. and also things changing all the time in a seismic way as soon as there is the slightest indication that the virus has managed to escape again from hotel quarantine :(

  • @jacoblojewski8729
    @jacoblojewski8729 3 ปีที่แล้ว +25

    If the tower has an odd number of discs, first move the smallest to the place you want the tower to end up. If even, move to the space you don't want the tower to end. Then just consistently follow the direction you moved the smaller disc to (clockwise/counterclockwise if arranged as a triangle, to the left/right with wraparound if arranged in a line).

  • @notahotshot
    @notahotshot 3 ปีที่แล้ว +60

    The best thing about Reve's puzzle; "We're going to have some cheese."

    • @timbeaton5045
      @timbeaton5045 3 ปีที่แล้ว +4

      But don't do it with camembert on a hot day. You'll end up with one super puddle of cheese.

    • @heaslyben
      @heaslyben 3 ปีที่แล้ว +4

      Did you wonder if the words "cheeses", "stools", and "moves" were chosen for (juvenile) humor? Perhaps by asking I've revealed too much about my own sense of humor.

  • @m4riel
    @m4riel 3 ปีที่แล้ว +55

    After checking a feel cases, I think that to get the tower from A to B, you start by moving the smallest disc to:
    • C, if there are 2n discs;
    • B, if there are 2n+1 discs.

    • @inyobill
      @inyobill 3 ปีที่แล้ว +4

      Ooooooo, nice thought, I'll have to verify. Well played mate.

    • @blackmephistopheles2273
      @blackmephistopheles2273 3 ปีที่แล้ว +4

      You can see that this has to be the case, due to how you move the first (0+1) disk.

    • @rmsgrey
      @rmsgrey 3 ปีที่แล้ว +7

      If you pay attention, you may notice that odd-numbered discs always move one way, while even numbered discs move the other way. Since moving the entire tower involves moving the largest disc once, you want it to move in the right direction. If it has the same parity as the smallest disc, you move them in the same direction; if it's the other parity, they move in opposite directions.

    • @EebstertheGreat
      @EebstertheGreat 3 ปีที่แล้ว +1

      @@blackmephistopheles2273 You can also work it out by feel as the OP suggests. There are only two possibilities, and they should depend only on the parity of the number of disks, because they depend only on the parity of some permutation in the computation. It all comes down to one choice, and it's deterministic, so either left first means left at the end or left first means right at the end.
      So you actually only need to check a single case. When there is n=1 disk, you move it onto the target peg. So if there are n=2k+1 disks, make your first move toward the target peg, and if n=2k, toward the other peg.

    • @ivanskopin7723
      @ivanskopin7723 3 ปีที่แล้ว +1

      When you don't have the corners but you have the pegs, I would phrase it as "if it's an even number, move the smallest disc to your final destination, if it's an odd number, move it to the peg that you don't want the tower to end up on".

  • @eshh183
    @eshh183 3 ปีที่แล้ว +72

    I remember watching 3B1B's video on Hanoi and feeling such awe, that a seemingly simple puzzle could weave recursion and binary counting together. I never thought anything could replicate that awe again!
    But damn you! Thank you soo much for making me experience that awe again, and this time much muchh more! I just can't wait to get on my computer and try to animate all the animations that you showed today (and perhaps even a generalised version for small n using Frame-Stewart algorithm?).
    But seriously lot's of love and respect man for making me fall in love with Maths over and over again!

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +16

      That's great. Cannot wait for the first animations to pop up :)

    •  3 ปีที่แล้ว +2

      Well, binary counting is recursive just by itself already.

    • @hybmnzz2658
      @hybmnzz2658 3 ปีที่แล้ว +1

      Honestly 3B1Bs most underrated video

    • @AAAAAA-gj2di
      @AAAAAA-gj2di 2 ปีที่แล้ว +1

      Don't cuss on a Great Professor who's probably much older than you

  • @RaquelFoster
    @RaquelFoster 3 ปีที่แล้ว +13

    In 1983 I got a Commodore 64 for my 8th birthday. My dad got some 5-1/4" floppy disks full of public domain BASIC games and one of them was Tower of Hanoi. That was the last time I heard of Tower of Hanoi. 🙂

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +8

      Pretty sure that was about the same time that I got my Commodore 64. I still remember animating the basic algorithm on this computer. Ah yes, the good old days :)

    • @RaquelFoster
      @RaquelFoster 3 ปีที่แล้ว +2

      @@Mathologer Back when animating anything was impressive! I read the Programmer's Reference Guide and was making sprites with a bunch of POKE statements and moving them around the screen. I thought I was going to get hired by Atari as soon as I got the word out! But anything was more advanced than those public domain games. I think they came out of user groups where people just mailed floppies around. I remember a reactor simulator called Nuke 64 which I wanted to like but it was ridiculously simple. But there was a Monopoly game called MONOPOLE-64 that I played a lot. There was some good-looking stuff that only used text mode graphics.

    • @HansMaurer.
      @HansMaurer. 3 ปีที่แล้ว +1

      @@Mathologer Did the same with the 80286 PCs that the school had bought for the first ever Grundkurs Informatik (using the recursive algorithm, learned about the circle patterns only later in university).

    • @Nikolas_Davis
      @Nikolas_Davis 3 ปีที่แล้ว +4

      The Tower of Hanoi was the first non-trivial recursion problem I came in contact with, as an example in an introductory textbook of CS in my freshman year at university. I was instantly hooked! :-) None of that boring factorial stuff; now, this was a *real*, powerful algorithm!

    • @RaquelFoster
      @RaquelFoster 3 ปีที่แล้ว +3

      @@Nikolas_Davis That's awesome. I don't know if I ever even saw the word recursion in school. I never had any interesting classes. In 1989 I begged my parents for a Turbo Pascal (With Objects! LOL!) compiler for my 14th birthday because I saw it in a store. Then in 1991 I got into a computer camp that had an application with several questions but only one that involved writing code. All you needed to do was find numbers that were both prime numbers and part of the Fibonacci series. I thought it was so easy I needed to make my answer clever to stand out (only 14 kids got into the camp at Ohio Supercomputer Center) so I made a super-small recursive function (not that I knew it was called recursion) that found Fibonacci numbers up to a limit then checked if they were prime as it fell back out. When I got to the camp I asked how they graded it and they said I was the only kid who even got it right LOL. But I got to play with a Cray Y-MP that summer! I hated school so much I kept dropping out because I'd do all my CS work in the first week of class then I'd just have classes I couldn't pay attention in. But one time I kept going until I got an internship before I dropped out. 🙂

  • @peter_p_r_zhang
    @peter_p_r_zhang 3 ปีที่แล้ว +22

    The toy maker himself wouldn't expect this video to come out one day during that time

    • @trueriver1950
      @trueriver1950 3 ปีที่แล้ว +6

      I think he was a rogue time lord himself. Not only that but both the doctor and the toy maker had probably time travelled to 2021 and seen the Mathologer video...

  • @PapaFlammy69
    @PapaFlammy69 3 ปีที่แล้ว +425

    Let's gooooooooooooooooooooooooo! :D

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +101

      Guten Abend Jens :)

    • @meeeshroom
      @meeeshroom 3 ปีที่แล้ว +20

      Papa Flammy ist hier!

    • @maxwellsequation4887
      @maxwellsequation4887 3 ปีที่แล้ว +4

      Yaaaaaaaaaaaayyyyyyyyyy

    • @adityaruplaha
      @adityaruplaha 3 ปีที่แล้ว +3

      Hello papa

    • @PapaFlammy69
      @PapaFlammy69 3 ปีที่แล้ว +26

      @@Mathologer Ich hoffe du hattest ein schönes Wochenende bis dato :3

  • @UCFc1XDsWoHaZmXom2KVxvuA
    @UCFc1XDsWoHaZmXom2KVxvuA 3 ปีที่แล้ว +9

    Increbile, the amount of astractions one's mind can demarcate around a given subject. Just wow, maths is beautiful

  • @conovan5081
    @conovan5081 3 ปีที่แล้ว +16

    I checked your channel three times this week, I was expecting this, LET'S GOOOOO

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +7

      Yes, sadly insanely busy at work and hardly any time for Mathologer :)

  • @AngryArmadillo
    @AngryArmadillo 3 ปีที่แล้ว +13

    These are some of your most visually satisfying animations to date, which is really saying something!

  • @stromboli183
    @stromboli183 3 ปีที่แล้ว +1

    Easily one of the best channels on all of youtube. Thank you once again for a very interesting, entertaining, learnful, and inspiring video, professor Burkard! 🙌

  • @AlexanderQ689
    @AlexanderQ689 3 ปีที่แล้ว

    Excellent video, I love the visuals & extending the tower of hanoi puzzle beyond what's typically talked about

  • @wompastompa3692
    @wompastompa3692 3 ปีที่แล้ว +4

    For n disks, the shorthand trick I remember is that odd heights start by moving the small disk to the destination peg and even starts by moving it to the intermediate peg.

  • @istariknight1
    @istariknight1 3 ปีที่แล้ว +4

    As others have shared, I also really enjoy Mathologer's take on these great topics even if other math channels I follow like 3B1B cover them! Every minute spent on this production by the team was worth its weight in gold (or cheese disks)
    I always get this sense like it's Christmas morning when I see a new video from you guys, thanks for pumping up my weekend!

  • @alvarezjulio3800
    @alvarezjulio3800 3 ปีที่แล้ว +1

    Once time again a Wonderful Video from Mathologer !!!
    Thank you.

  • @10gbo_pizza
    @10gbo_pizza 3 ปีที่แล้ว +2

    Sir can I say, despite the time, your videos are ABSOLUTELY AMAZING! KEEP UP THE GOOD WORK! :)

  • @inyobill
    @inyobill 3 ปีที่แล้ว +15

    31:05 I believe I read, was mentioned in one of my Logic classes, or ???: For every Provable True Theorem, there are an infinite number of True Unprovable theorems. "There are more things in heaven and earth, Horatio, than are dreamt of in your philosophy.".

  • @NatePrawdzik
    @NatePrawdzik 3 ปีที่แล้ว +33

    The Toymaker is Hanoi'ing me again.

  • @pisquaredoversix
    @pisquaredoversix 3 ปีที่แล้ว +2

    I have seen a lot of comments before saying that they needed the video before, but I didn't expect this one to be one of those. This was the topic of my research paper for my gifted class last year, specifically the smallest amount of moves to win a k-poled Hanoi Tower, and I plan to carry on this year. I haven't finished the video, but thank you for this wonderful video anyway. Cheers from Korea!
    Edit: Never thought about 4-peg Hanoi Towers with the concept of superdisks. Thanks again.

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +2

      Well, have fun with your research paper :)

  • @Lightn0x
    @Lightn0x 3 ปีที่แล้ว +11

    I used to solve towers of hanoi on fights because I had no internet. Solving the 10-peg version with 1023 moves must've been one of the proudest moments in my life :D
    Edit: huh, I didn't know the "smallest disk" trick explained at 12:18. I just tried to follow the recursive algorithm in my head. Way to trivialize my life's achievment, Mathologer! /s

  • @maxsch.6555
    @maxsch.6555 3 ปีที่แล้ว +5

    Oh, what could be nicer than a weekend with a mathologer video :)

  • @melekhine
    @melekhine 3 ปีที่แล้ว +2

    Every one of your videos is so amazing, Professor Burkard. Best on the internets

  • @moonblaze2713
    @moonblaze2713 3 ปีที่แล้ว +6

    Bioware put this in KotOR, and I had to memorize this thankfully simple recipe because I did multiple playthroughs. Years later, they put it in Mass Effect 1 and I still remembered it. And years later I saw this video and still remembered it.
    Stuff you do repeatedly as a kid really sticks with you, huh?

  • @Hahahahaaahaahaa
    @Hahahahaaahaahaa 3 ปีที่แล้ว +1

    I think, because of how common the Tower puzzle is, and how little I've thought about it before, this is one of the most beautiful videos you've done. Despite many years of studying more complex topics, making "simple" problems elegant often gives me the greatest appreciation of mathematics. Thank you as always!

  • @walrusman8691
    @walrusman8691 3 ปีที่แล้ว +20

    This kind of single move algorithms often show up in computer science and an often overlooked follow up question is if their were "multithreading" where if two subsequent movements occurred to and from different pegs they could be done simultaneously as 1 move. Obviously this would only apply to larger n but I would be curious if the solutions for that were actually superior given how ordered the solutions seem to be already.

    • @heaslyben
      @heaslyben 3 ปีที่แล้ว +2

      I love that question. It makes me think of context switching as well. Could any process (aka intelligent but forgetful prisoner) wake up, inspect the current state of the board, and make the next correct move? My instinct is "yes" but I'm not sure.

    • @aeleron0577
      @aeleron0577 3 ปีที่แล้ว

      @@heaslyben probably. Of course it depends on the actual problem, but one could use a hamming code approach for that. Aka coding a failsafe

  • @sidazhou
    @sidazhou 3 ปีที่แล้ว

    Already smashed the like button multiple times before Intro was finished. Such was the enthusiasm to learn.

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +1

      That's great :)

  • @TheJoaovascorodrigue
    @TheJoaovascorodrigue 3 ปีที่แล้ว

    Your videos are mind-ticklers! Thank you

  • @Jukka70
    @Jukka70 3 ปีที่แล้ว +1

    So happy to see the video for this month. Wish they were more times then once a month, but am sure it takes a long time to make these, and happy that you make them

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +2

      Yes, sadly my uni job keeps me insanely busy these days. That and family leaves hardly any time for Mathologer. Anyway, I'll keep trying to put one out every month.... :)

  • @notabotta3901
    @notabotta3901 3 ปีที่แล้ว +1

    Couldn’t be happier to see this video and try the challenges!

  • @_majortom_
    @_majortom_ 3 ปีที่แล้ว

    beautifuly done as always. I have enjoyed every part of this video. thanx!

  • @sidimohamedbenelmalih7133
    @sidimohamedbenelmalih7133 3 ปีที่แล้ว +13

    Yes mathologer video when i'm bored is the best of the best

  • @danielmassart
    @danielmassart 3 ปีที่แล้ว +5

    for the record, T. Bousch also has a strong contender in the "best title for a math paper, ever" category : Le Poisson n'a pas d'arête (Annales de l'Institut Henri Poincaré, 1999)

    • @NoNameAtAll2
      @NoNameAtAll2 3 ปีที่แล้ว +1

      Translate?

    • @somebodyhere3160
      @somebodyhere3160 3 ปีที่แล้ว

      @@NoNameAtAll2 google translate tells me this:the Fish has no bones

  • @stingrayx2182
    @stingrayx2182 3 ปีที่แล้ว

    One of your best videos, thanks!

  • @cybersecuritytutorials8762
    @cybersecuritytutorials8762 2 ปีที่แล้ว +1

    Amazing!!!
    Enjoy your storytelling style to explain the mathematical concepts and algorithms.

  • @trtlphnx
    @trtlphnx 3 ปีที่แล้ว +1

    Love Your Mind, My Friend,,, Keep up the Incredible Work; You have a #1 Fan Here!!!

  • @DoReMeDesign
    @DoReMeDesign 3 ปีที่แล้ว +9

    2nd problem is 3^n because there are n discs, each of which has 3 'choices' of pegs - same as the number of vertices on the sierpinski triangle
    3rd problem can be done by comparing coefficients of 12/59 and 18sqrt(17)/1003, upon which irrational parts drop out - not sure I want to do this..
    -btw, thanks Mathologer!

    • @HansMaurer.
      @HansMaurer. 3 ปีที่แล้ว +3

      3^n-1 actually (for the path length)

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +4

      @@HansMaurer. That's it :)

    • @keshavgoel2310
      @keshavgoel2310 3 ปีที่แล้ว +1

      For the second problem, recursion is T(n) = 3T(n-1) +2 as largest disc moves twice and the n-1 disc pile has to be moved from one extreme to another thrice. Solving the recursion gives the promised beautiful answer - 3^n-1

    • @taibilimunduan
      @taibilimunduan 3 ปีที่แล้ว

      less one, because the initial position does not count as a move

  • @manorueda1432
    @manorueda1432 3 ปีที่แล้ว +1

    Funny and awesome, as always! I've enjoyed it.
    I'll think about the puzzle with for and five pegs!

  • @johnchessant3012
    @johnchessant3012 3 ปีที่แล้ว +1

    Brilliant and very satisfying video!

  • @troemax
    @troemax 3 ปีที่แล้ว

    Wonderful video. Thank you for making these!

  • @abrvalg321
    @abrvalg321 3 ปีที่แล้ว +4

    0:56 that puzzle becomes really hard really quick if allow to input not only number disks but sticks as well.

  • @denny141196
    @denny141196 3 ปีที่แล้ว +2

    Decided to implement in python before watching. An interesting point I came across was that when recursing, the midpoint and destination swap for subtower move (so the biggest disc can move to the destination unimpeded). As the algorithm recurses down to the base case of 1 (not 0), there are n-1 such midpoint/destination swaps for a tower of size n.
    Hence, for towers with an odd number of discs, there are an even number of mid/dst swaps, which all cancel out -> first move should be the first disc on to the intended overall destination.
    Vice versa for even number of discs.

  • @TrimutiusToo
    @TrimutiusToo 3 ปีที่แล้ว +4

    I figured out best solution for tower of hanoi when i was 6... My dad gave to me tower of hanoi puzzle with 8 peaces and so that i don't bother him said that i should find best solution and left me like that, and then was very surprised that 3 hours later i came to him and said "255", he already even forgot that he gave me the puzzle, but back in those days i figured out the recursive solution to tower of hanoi which impressed my father quite a bit... I was always good with recursive algorithms...

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +2

      Cool :)

    • @trueriver1950
      @trueriver1950 3 ปีที่แล้ว +1

      The iterative algorithm is harder to spot, and would have impressed him even more
      (I won't give it here, as several other commented already have)

  • @vivekpal1004
    @vivekpal1004 3 ปีที่แล้ว

    Such a great explanation! Excellent!!!

  • @StankyPickle1
    @StankyPickle1 3 ปีที่แล้ว

    Beautiful visualizations!

  • @KillianDefaoite
    @KillianDefaoite 3 ปีที่แล้ว +8

    Me every time a Mathologer video comes out: *visible excitement*

  • @woodpecker8546
    @woodpecker8546 3 ปีที่แล้ว

    What a fantastic video again! Thank you very much!

  • @Person1873
    @Person1873 3 ปีที่แล้ว +4

    The trick I always used for the tower of Hanoi is based on odd or even quantity of discs.
    If you have an odd number of discs then the first move will be to the target tower.
    If you have an even number, then your first move will be to the other empty tower.

  • @tonyalanmarchant7330
    @tonyalanmarchant7330 3 ปีที่แล้ว +7

    I love the little giggles. Could be a bady in a bond movie

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +4

      If they ever offer me a role as a mathematical supervillain I'd definitely go for it :)

    • @tonyalanmarchant7330
      @tonyalanmarchant7330 3 ปีที่แล้ว +1

      @@Mathologer you most defo should.an if the role comes along? I assume you know all about percentages 😁

  • @jorgevegarevolledo
    @jorgevegarevolledo 3 ปีที่แล้ว

    Todos tus videos son espectaculares. Gracias por tomarte el trabajo de hacerlos, son realmente inspiradores.

  • @chiranjivipokharel1152
    @chiranjivipokharel1152 3 ปีที่แล้ว

    Always so curious to see vedios , thanks a lot mythologer , love from Nepal

  • @dctcristino
    @dctcristino 3 ปีที่แล้ว +1

    Perfect, my friend! Thanks!

  • @leonidassavalas745
    @leonidassavalas745 3 ปีที่แล้ว +1

    There was no Easter egg at the end, but I always watch the entire (always wonderful) video(s). Thank you, Mathologer!

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +2

      That's great :)

  • @fabiopaiva33
    @fabiopaiva33 3 ปีที่แล้ว +1

    Thanks for the video!!
    Greetings from Brazil :)))

  • @surfing_youtube
    @surfing_youtube 2 ปีที่แล้ว

    Thank you for this excellent video. It was worth watching.

  • @namantenguriya
    @namantenguriya 3 ปีที่แล้ว +9

    •Always loving your videos. 🥰🥰🥰
    Love from India 🇮🇳🇮🇳🇮🇳.
    •By the way, if you plug in 3 for n, you get 《946/243》(=3.893)
    •Please make videos on ☆☆☆ Unsolved problems in Mathematics ☆☆☆.

  • @SaveSoilSaveSoil
    @SaveSoilSaveSoil 2 ปีที่แล้ว

    I find myself revisiting your hugely helpful references again. Kudos to Team Mathologer!

    • @Mathologer
      @Mathologer  2 ปีที่แล้ว +1

      Glad to hear it!

  • @dcterr1
    @dcterr1 3 ปีที่แล้ว +1

    By the way, Dr. Who was a great show! Great choice for introducing the Tower of Hanoi puzzle!

  • @pullingrabbitsouttaahat
    @pullingrabbitsouttaahat 3 ปีที่แล้ว

    Another Gem From Mathologer. Hats Off !

  • @benYaakov
    @benYaakov 3 ปีที่แล้ว +1

    Very nice , keep sharing such knowledge at TH-cam platform :)

  • @xevira
    @xevira 3 ปีที่แล้ว +3

    13:50
    if n is odd: clockwise
    if n is even: counter-clockwise
    or another way to phrase it:
    if n is odd: first move is to the target position
    if n is even: first move is to the OTHER position

  • @Tiessie
    @Tiessie 3 ปีที่แล้ว

    Your videos are so interesting and inspiring

  • @technowey
    @technowey 3 ปีที่แล้ว

    Thank you for another excellent video.

  • @laierr
    @laierr 3 ปีที่แล้ว

    I'm so glad to see (literally) that your color scheme became more colorblind-friendly!

  • @d4django
    @d4django 3 ปีที่แล้ว +1

    I am ready for the tomaker now! Thankyou Mr Mathologer

  • @casanova2829
    @casanova2829 3 ปีที่แล้ว

    Incredible explanation!

  • @paulklee5790
    @paulklee5790 3 ปีที่แล้ว

    I distinctly remember seeing this on our steam driven television the first time round... by then I’d graduated from watching from behind the sofa (for safety reasons...), it had a big impact on me ... I made a version of the game at school and started a craze for playing it that lasted two whole weeks! Nerd heaven.....

  • @prashantshukla6018
    @prashantshukla6018 3 ปีที่แล้ว

    Oh gosh I was craving such stuffs 😂. Love ur creations sir huge love and respect from India . Thank u sir!

  • @realcygnus
    @realcygnus 3 ปีที่แล้ว

    Superb .... as always.

  • @danpost5651
    @danpost5651 3 ปีที่แล้ว +2

    14:00 For odd number of disks, move clockwise; for even, move counter-clockwise. Easy to see. if one disk (or odd), move directly to ending peg; otherwise, not.

  • @blackmephistopheles2273
    @blackmephistopheles2273 3 ปีที่แล้ว +2

    #1: Nine disks need forty-one (41) moves. My solution is the "minimum of (two times a smaller number of disks plus the minimum of the remaining disk moves) method.
    #2: An observation: if d (# of disks) < p (# of pegs), then you ALWAYS only need 2*d-1 moves. Basically, having more pegs than disks means you can move every disk to its own peg, including the base disk (to the designated ending peg), then move all of the other disks back on to the next bigger disk, which you should have already moved to that ending peg: (d - 1) + 1 + (d - 1) = 2d - 1.
    #3: Likewise, if d = p, then m = 2d + 1, since you will have to move whichever disk is on the ending peg (or move another disk, if the ending peg is the only one available to the biggest disk), move the biggie, move the disk you had to move beforehand, and then move all the other disks onto the biggie: (d - 1) + 1(clear off the ending peg) + 1(biggie) + 1(split the double stack up with the starting peg) + (d - 1) = 2d + 1.

  • @marcoantonio7648
    @marcoantonio7648 3 ปีที่แล้ว

    havent watch it yet, but its a gift to watch your videos.

  • @hamiltonianpathondodecahed5236
    @hamiltonianpathondodecahed5236 3 ปีที่แล้ว +7

    "Oh , I know about this puzzle"
    "how tf I never thought about multiple pegs"

  • @HAL-oj4jb
    @HAL-oj4jb 3 ปีที่แล้ว +6

    I didn't even notice that the movie and tv references were gone, nice to see a revival!

    • @trueriver1950
      @trueriver1950 3 ปีที่แล้ว +1

      Try opening the pod bay doors...

  • @ripe_aces
    @ripe_aces 3 ปีที่แล้ว +1

    14:43, this wicked sense of humor had me in stitches.

  • @Mutual_Information
    @Mutual_Information 3 ปีที่แล้ว

    Tower of Hanoi is a super popular interview question, so much so that I bet interviewers have to tweak the question so it's new to interviewees. I imagine asking about more pegs is a frequent extension. Now I feel prepared. Great vid

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +5

      A simple solution is to add more pegs before you start moving the discs. For 10 discs and 11 pegs the puzzle becomes trivial :)

  • @fibbooo1123
    @fibbooo1123 3 ปีที่แล้ว

    Awesome video!

  • @samuelwaller4924
    @samuelwaller4924 3 ปีที่แล้ว

    I just recently found a code golf where the challenge was to quine that output a unique program every iteration, without repeat, for however many iterations. I immediately thought of Gray code, and have been absorbed. This is great!

  • @AmitSingh-sf5qp
    @AmitSingh-sf5qp 3 ปีที่แล้ว +10

    My interest in maths came back after my exam .

  • @manos_sardis
    @manos_sardis 3 ปีที่แล้ว

    I just can't stop watching these videos

  • @reecec626
    @reecec626 3 ปีที่แล้ว

    These animations are neat as a pin!

  • @mathyland4632
    @mathyland4632 3 ปีที่แล้ว +2

    Is there still a video in the works about the unsolvability of the quintic?

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +4

      Sure, the problem is to find the time. Since COVID my job at uni really got insane and I just don't have enough time to really go for a complex project like this :(

  • @buxeessingh2571
    @buxeessingh2571 3 ปีที่แล้ว +2

    For those who don't know: the reason you only saw a still and heard an audio is that only photos from the TV broadcast and a duplicate audio of the telecast are what BBC have in the archives of the first three episodes.
    Addendum: there was a proposed sequel to "The Celestial Toymaker" called "Nightmare Fair". Rumour had it that an early draft of the script included the Doctor solving the minimal path problem discussed here for the Trilogic game.

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +1

      Had not heard about this before :)

  • @vincentproud6589
    @vincentproud6589 3 ปีที่แล้ว +1

    I love your content.
    I only hope, one day, we get more Euler-Maclaurin stuff! :D

    • @Mathologer
      @Mathologer  3 ปีที่แล้ว +2

      One day ... If only I had more time to do all the videos I'd like to make ...

  • @xCorvus7x
    @xCorvus7x 3 ปีที่แล้ว +2

    13:27
    The doctor has to move the tip counter-clockwise because B in that picture corresponds to the lower right corner of the triangle we had looked at before.
    In general, if you have a tower with n disks, you have to move the tip clockwise for odd n and counter-clockwise for even n for the tower to end up at B (according to this picture).
    Moving a tower with an even number of disks to B means that you first move a tower with one less disk and thus an odd number of disks to C and since a single-disk tower can be moved with one move only, the tip of a tower with an odd number of disks moves initially to the place where the whole tower will eventually end up.
    Therefore, if the tower has an even number of disks, the tip has to move to a different place than the final location.

  • @1234dck
    @1234dck 3 ปีที่แล้ว

    Brilliant videos

  • @Veptis
    @Veptis 3 ปีที่แล้ว +1

    It's often used to teach recursion. And last semester our professor used Fibonacci sequence and towers of Hanoi as two examples to show different programming languages. Including postscript, which was quite fascinating

  • @DavidPanofsky
    @DavidPanofsky 3 ปีที่แล้ว +1

    The puzzle at 16:35 is the one the Celestial Toymaker should use if he wants to hanoi you.

  • @mickwilson99
    @mickwilson99 ปีที่แล้ว

    Love the last animation!

  • @goodboi650
    @goodboi650 3 ปีที่แล้ว +1

    Thank you for what you do. I will go to sleep dreaming of discs and pegs now :)

  • @JoeTaber
    @JoeTaber 3 ปีที่แล้ว +2

    I feel like this must have some application in cpu register allocation or cache hierarchies. Especially interesting in light of the idea of grouping disks into super disks etc.

  • @swirlcrop
    @swirlcrop 3 ปีที่แล้ว

    Thanks for a great video.