The Magnetic Tower of Hanoi 1 The Classical Tower of Hanoi 2 Classical ToH – video-clip 1 (0:53) Click link to play a YouTube video 1. http://www.youtube.com/watch?v=EHtk7kZqoVY 3 Positional Notations 4 Babylonian mathematics (3-rd millennium BC) It originated with the ancient Sumerians in the 3 rd millennium BC ,was transmitted to the Babylonians , and is still used - in modified form - for measuring time , angles , and geographic coordinates . http://en.wikipedia.org/wiki/Base_60 5 A short reminder of bases (“Positional Notation”) Positional notation From Wikipedia, the free encyclopedia Indian mathematicians developed the Hindu-Arabic numeral system , the modern decimal positional notation, in the 9-th century . 2506 = 2 x 103 + 5 x 102 + 0 x 101 + 6 x 100 [ ] (Pos. – 1) Number = SUM npos.*Base http://en.wikipedia.org/wiki/Place_value_system 6 A short reminder of bases – base 2 Base 2 Weight 24 23 22 21 20 Position 5 4 3 2 1 Number 1 0 1 1 1 10111(2) = 1*24 +0*23 +1*22 +1*21 +1*20 10111(2) = 16(10) + 4(10) + 2(10) + 1(10) = 23(10) http://en.wikipedia.org/wiki/Place_value_system 7 A short reminder of bases – base 3 Base 3 Weight 34 33 32 31 30 Position 5 4 3 2 1 Number 1 0 1 2 2 10122(3) = 1*34 +0*33 +1*32 +2*31 +2*30 10122(3) = 81(10) + 9(10) + 6(10) + 2(10) = 98(10) http://en.wikipedia.org/wiki/Place_value_system 8 The Classical Tower and base 2 9 A. The Classical Tower of Hanoi [ToH] k=N k=2 k=1 A model set of the Towers of Hanoi (with 8 disks) The classical Tower of Hanoi "puzzle" or "mathematical game" invented by the French mathematician Edouard Lucas in 1883. http://en.wikipedia.org/wiki/Tower_of_Hanoi 10 Classical ToH – video-clip 2 (1:14) Click link to play a YouTube video 2. http://www.youtube.com/watch?v=3eGBhSSxffM 11 ToH – Puzzle Description Puzzle Components: Three equal posts A set of N different-diameter disks Puzzle-start setting: N disks arranged in a bottom-to-top descending-size order on a "Source" Post Move: Lift a disk off one Post and land it on another Post Disk-placement rules: The Size Rule: A small disk can not "carry" a larger one (Never land a large disk on a smaller one) Puzzle-end state: N disks arranged in a bottom-to-top descending-size order on a "Destination" Post (one of the two originally-free posts) 12 ToH – Recursive Relations P ( k 1) 2 P ( k ) S ( N 1) 2 S ( N ) 1 13 ToH – Number of Moves P (k ) 2 N S (N ) 2 k 1 k 1 2 N 1 k 1 k N 1 2 3 4 5 6 7 1 1 2 1 2 3 1 2 4 4 1 2 4 8 5 1 2 4 8 16 6 1 2 4 8 16 32 7 1 2 4 8 16 32 64 8 1 2 4 8 16 32 64 8 128 SUM 2N - 1 1 1 3 3 7 7 15 15 31 31 63 63 127 127 255 255 14 Classical ToH – spans “base 2” k N 1 2 3 4 1 1 2 20 1 2 3 20 1 21 2 4 4 20 1 21 2 22 4 8 20 21 22 23 SUM 2N - 1 1 1 3 21-1 3 7 22-1 7 15 23-1 15 24-1 15 A “Base 2” game Base 2 Element (k) 1 2 3 4 5 # of moves 1 2 4 8 16 # of moves 20 21 22 23 24 k=N k=2 k=1 16 The Classical Tower Spans base 2 17 Challenge: invent a “base 3” game Can we invent a game that Spans base 3? 18 Elements of a“Base 3” game Base 3 Element (k) 1 2 3 4 5 # of moves 1 3 9 27 81 # of moves 30 31 32 33 34 19 Challenge: invent a “base 3” game So - can we invent a game that Spans base 3? 20 Yes we can 21 MToH – video-clip 3 (1:29) Click link to play a YouTube video 3. http://www.youtube.com/watch?v=nUoHHeaJ4eI 22 B. The Magnetic Tower of Hanoi [MToH] 23 MToH – when we where Young and Brave Yaron (10) and a home-made Magnetic Tower of Hanoi Rehovot, Israel - Autumn 1984. 24 MToH – Puzzle Description Puzzle Components: Three equal posts. A set of N different-diameter disks Each disk's "bottom" surface is colored Blue and its "top" surface is colored Red Puzzle-start setting: N disks arranged in a bottom-to-top descending-size order on a "Source" Post The Red surface of every disk in the stack is facing upwards Move: Lift a disk off one post Turn the disk upside down and land it on another post Disk-placement rules: ♣The Size Rule: A small disk can not "carry" a larger one (Never land a large disk on a smaller one) ♣The Magnet Rule: Rejection occurs between two equal colors (Never land a disk such that its bottom surface will touch a co-colored top surface of the "resident" disk) Puzzle-end state: N disks arranged in a bottom-to-top descending-size order on a "Destination" Post (one of the two originally-free posts) 25 MToH – Solving the N=2 Puzzle 2 1 4 3 26 Colored MToH – video-clip 4 (1:24) Click link to play a YouTube video 4. http://www.youtube.com/watch?v=D_xfuCOh1S0 27 B1. The Colored MToH S D I D I S I D 28 The Colored MToH – Number of Moves P100 ( k ) 3 N S 100 ( N ) 3 k 1 k 1 k 1 k N 1 2 3 4 5 6 7 1 1 2 1 3 3 1 3 9 4 1 3 9 27 5 1 3 9 27 81 6 1 3 9 27 81 243 7 1 3 9 27 81 243 729 8 1 3 9 27 81 243 729 3 N 1 3 1 1 8 2187 SUM (3N - 1)/2 1 1 4 4 13 13 40 40 121 121 364 364 1093 1093 3280 3280 29 Colored MToH – spans “base 3” k N 1 2 3 4 1 1 2 30 1 3 3 30 1 31 3 9 4 30 2 1 31 2 3 32 2 9 27 30 2 31 2 32 2 33 2 5 SUM (3N–1)/2 1 1 (31-1)/2 4 4 (32-1)/2 13 13 (33-1)/2 40 40 (34-1)/2 30 Challenge met And the fun just begins 31 MToH – The Three Versions B1. The Colored MToH B2. The Semi-Free MToH B3. The Free MToH 32 B2. The Semi-Free MToH SS ID DI An MToH is Semi-Free if ♣ One of its posts – say – S, is permanently colored – say Red ♣ Another post – say – D, is permanently and oppositely colored ♣ The third post – I - is Free (has a Neutral color at the start of the algorithm) ♣ We need to move N disks from Post S to Post D using Post I 33 The Semi-Free MToH – Number of Moves k - odd PSF ( k ) 2 3 k 2 3 k 1 k - even 3 2 3 1 2 3 k 2 3 1 3 1 2 1 PSF ( k ) 2 3 N - odd S SF ( N ) ( 3 k N N 1 1 N 1) 2 k 2 3 k 1 3 1 3 1 2 3 k 2 3 2 3 1 2 N - even 3 N 1 3 3 1 2 3 0 N 1 2 4 S SF ( N ) ( 3 5 N 1 6 N 1) 7 1 1 2 1 3 3 1 3 7 4 1 3 7 21 5 1 3 7 21 61 6 1 3 7 21 61 183 7 1 3 7 21 61 183 547 8 1 3 7 21 61 183 547 3 N 1 3 3 1 2 8 1 N 2 2 SUM 1 4 11 32 93 276 823 1641 2464 34 The Semi-Free MToH – Duration Ratio N S SF ( N ) S 100 ( N ) 3 4 35 The Free MToH • The “67” Algorithm • The “62” Algorithm 36 The Free MToH – video-clip 5 (2:43) Click link to play a YouTube video 5. http://www.youtube.com/watch?v=bZtx5gexddI 37 MToH FREEDOM “It is (this) FREEDOM that makes the Magnetic Tower of Hanoi Puzzle so COLORFUL” 38 B3. The Free MToH – The “67” Algorithm P67 (1) 1 P67 ( k ) 2 P100 ( k 1) 1 k 2 S 67 ( N ) S 67 ( N 1) 4 S 100 ( N 2 ) 3 39 The “67” Algorithm – Number of Moves P67 (1) 1 P67 ( k ) 2 3 2 3 N S 67 ( N ) 1 k 2 k 2 1 3 1 k 2 N 1 N 1 k 2 k N 1 2 3 4 5 6 7 1 1 2 1 3 3 1 3 7 4 1 3 7 19 5 1 3 7 19 55 6 1 3 7 19 55 163 7 1 3 7 19 55 163 487 8 1 3 7 19 55 163 487 8 1459 SUM 3(N-1) + N-1 1 1 4 4 11 11 30 30 85 85 248 248 735 735 2194 2194 40 The “67” Algorithm – Duration Ratio N S 67 ( N ) S 100 ( N ) 2 3 41 B3. The Free MToH – The “62” Algorithm P62 ( k ) P67 ( k ) k 3 P62 ( k ) 2 P100 ( k 2 ) 2 P100 ( k 3 ) k 3 P67 ( k 1) P67 ( k 2 ) PSF ( k 3) S 62 ( N ) S 67 ( N ) N 3 S 62 ( N ) 2 S 100 ( N 2 ) 2 S 100 ( N 3 ) 3 1 2 S 67 ( N 1) S 67 ( N 2 ) S SF ( N 3 ) N 3 3 1 1 42 The “62” Algorithm – Number of Moves k N 1 2 3 4 5 6 7 1 1 2 1 3 3 1 3 7 4 1 3 7 19 5 1 3 7 19 53 6 1 3 7 19 53 153 7 1 3 7 19 53 153 455 8 1 3 7 19 53 153 455 8 SUM 1 4 11 30 83 236 691 1359 2050 43 The “62” Algorithm – Duration Ratio N S 62 ( N ) S 100 ( N ) 67 108 44 “SF” ; “67” ;“62” – Duration Ratio S SF ( N ) N 3 N 1 S 100 ( N ) 3 N 1 3 N 2 1 ( N 1) / 3 N S 100 ( N ) 3 11/ 3 S 67 ( N ) S 62 ( N ) S 100 ( N ) N 2 3 N 2 ( 3 1) 2 2 3 4 ( N 1 ) n 2 3 2 3 N 3 3 3 N N 4 2 3 N 4 ( 3 1) 2 67 108 45 “SF” ; “67” ; “62” – Duration-Ratio Curves "SF", "67", "62" efficiency curves 1 "SF" "SF" limit "67" "67" limit "62" "62" limit 0.95 S-XX(N)/S-100(N) 0.9 0.85 0.8 3/4 0.75 2/3 0.7 0.65 0.6 67/108 0.55 0.5 1 2 3 4 5 6 7 8 9 10 11 12 Number of disks in the stack (N) 46 The double-pan balance Puzzle 47 Effective (minimum # of) weights for a balance 1 2 3 40 How many? What values? 48 Minimum # of weights - continue 1 2 40 3 27 9 1 3 49 Minimum # of weights - continue 9 1 3 27 1 through 40 9 1 81 3 1 through 121 27 50 Elegance of the “67 Algorithm” 51 The “67” Algorithm – find a simple rule k N 1 1 2 3 1 2 3 4 5 6 7 8 SUM 1 4 11 1 3 1 3 7 4 5 6 1 3 7 19 1 3 7 19 55 1 3 7 19 55 163 7 8 1 3 7 19 55 163 487 1 3 7 19 55 163 487 P67 ( k ) 2 3 30 85 248 k 2 1459 735 2194 1 52 What about the total number of moves? The “Free 67” Magnetic Tower of Hanoi Total number of moves N 1 2 SUM S 67 ( N ) 3 N 1 N 1 1 S 67 (1) 3 4 S 67 ( 2 ) 3 1 4 0 0 1 1 11 S 67 ( 3 ) 3 2 2 11 4 30 S 67 ( 4 ) 3 3 3 30 5 85 S 67 ( 5 ) 3 4 4 85 3 53 Recursive Relations 54 Recursive Relations - 1 The “100” Algorithm P100 ( k 1) 3 P100 ( k ) S 100 ( N 1) 3 S 100 ( N ) 1 The “67” Algorithm P67 ( k 1) 3 P67 ( k ) 2 k 2 S 67 ( N 1) 3 S 67 ( N ) 2 N 3 55 Recursive Relations - 2 The “SF” Algorithm PSF ( k 1) 3 PSF ( k ) k - odd PSF ( k 1) 3 PSF ( k ) 2 k - even S SF ( N 1) 3 S SF ( N ) N 1 N - odd S SF ( N 1) 3 S SF ( N ) N 2 N - even 56 Recursive Relations - 3 The “62” Algorithm P62 ( k 1) 3 P62 ( k ) 6 P62 ( k 1) 3 P62 ( k ) 4 k 4 k 4 k - odd k - even S 62 ( N 1) 3 P62 ( N ) 5 ( N 3 ) 3 N 3 S 62 ( N 1) 3 P62 ( N ) 5 ( N 3 ) 2 N 3 N - odd N - even 57 Recursive Relations - 4 All without exception: next 3 ( current ) ... 58 Color Crossings 59 MToH – Color Crossings - 1 Color of a given post = Red → Neutral → { Red Blue 60 MToH – Internet Movie A "movie" showing the "62" Algorithm solving a height five MToH in (only) 83 moves: http://www.numerit.com/maghanoi/ 61 MToH – Internet Movie Shown in the movie – solution of the height 5 MToH puzzle by (only) 83 moves Click link to play a YouTube video 6. http://www.youtube.com/watch?v=sysN4-6zXNo It is Freedom that makes the MToH so colorful. 62 MToH – Color Crossings - 2 P o st c o lo r [1 = R ; 0 = N ; -1 = B ] The "100" Algorithm ; N = 5 [121 moves] 1 Source Intermediate Destination 0 -1 0 10 20 30 40 50 60 70 80 90 100 110 120 Move-number The “100” Algorithm – NO color crossings 63 MToH – Color Crossings - 3 P o st c o lo r [1 = R ; 0 = N ; -1 = B ] The "62" Algoritm ; N = 5 [83 moves] 1 0 Source Intermediate Destination -1 0 10 20 30 40 50 60 70 80 Move-number The “62” Algorithm – EIGHT color crossings 64 Next 65 “Tower Theory” – Further Modifications Further expansions: ♣ Puzzle-start setting ♣ Number of posts ♣ “Disk" structure (may "quickly" lose its circ. symmetry) ♣ Move rules ♣ Puzzle-end state "Tower Field” in Number Theory? 66 References 67 Gathering 4 Gardner 9 – Atlanta, GA (March `10) 68 Gathering 4 Gardner 9 – Atlanta, GA (March `10) Game inventor: Martin Gardner Figure 6. An artist friend drew this picture for Gardner, illustrating the maximum number of pieces into which a bagel can be sliced by three planes. 69 Gathering 4 Gardner 9 – mini-MToH 70 G4G9 - Handouts 71 References [1] "The Magnetic Tower of Hanoi", Uri Levy, Journal of Recreational Mathematics 35:3, to be published (~May 2010) [2] Paper download: http://arxiv.org/abs/1003.0225 [3] "Movie“ (and paper download, different Abstract): http://www.numerit.com/maghanoi [4] Contact: uri@vicsor.com 72 Cornell University Library http://arxiv.org/ abs/1003.0225 73 Realization 74 The Magnetic Tower of Hanoi – Realization 75 The “Colored” Magnetic Tower of Hanoi 76 “Free” or “Classical” MToH 77 Oops! 78 Illegal Move! 79 One-Two- Three – GO! 80 The End 81