Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

Divide and conquer: The Tower of Hanoi

With this strategy, solving a problem requires two or more recursive solutions. For starters, let's consider a classic puzzle, invented by a French mathematician, Édouard Lucas, in the XIX century. It seems that there is a temple in India, with three posts with 64 golden disks of decreasing diameter. The priests have to move the disks from the first post to the last one, following two rules: only one disk can be moved at a time, and a larger disk can never be placed on top of a smaller disk. According to the legend, when the 64 disks are moved, the world will end. This puzzle is usually marketed under the name Towers of Hanoi (yes, they changed countries!) with less than 10 disks. See figure 9.1:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content