{"id":1441,"date":"2018-02-12T01:01:41","date_gmt":"2018-02-12T01:01:41","guid":{"rendered":"http:\/\/zatizi.com\/?p=1441"},"modified":"2018-02-12T01:01:41","modified_gmt":"2018-02-12T01:01:41","slug":"the-tower-of-hanoi-in-python","status":"publish","type":"post","link":"https:\/\/zatizi.com\/?p=1441","title":{"rendered":"The Tower of Hanoi in Python\u00a0?"},"content":{"rendered":"<pre># Tower of Hanoi (puzzle)\n# invented by \u00c9douard Lucas\n# recursive solution in Python\n\ndef Hanoi (disks,sourcePeg, sparePeg, targetPeg):\n    # disks &gt; 0\n    if disks:\n        Hanoi (disks-1,sourcePeg,targetPeg,sparePeg)\n        print (\"I move disk\", disks, \"from\",sourcePeg,\"to\",targetPeg)\n        Hanoi (disks-1,sparePeg,sourcePeg,targetPeg)\n\n# 4 disks on peg A to be moved to peg C\nHanoi (4,\"peg A\",\"peg B\",\"peg C\")\nprint ()\nprint (\"DONE !\")\n\n# program: The Tower of Hanoi\n# implementation in Python 3.x: A.-P. Gaspar\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p># Tower of Hanoi (puzzle) # invented by \u00c9douard Lucas # recursive solution in Python def Hanoi (disks,sourcePeg, sparePeg, targetPeg): # disks &gt; 0 if disks: Hanoi (disks-1,sourcePeg,targetPeg,sparePeg) print (&#8220;I move disk&#8221;, disks, &#8220;from&#8221;,sourcePeg,&#8221;to&#8221;,targetPeg) Hanoi (disks-1,sparePeg,sourcePeg,targetPeg) # 4 disks on peg A to be moved to peg C Hanoi (4,&#8221;peg A&#8221;,&#8221;peg B&#8221;,&#8221;peg C&#8221;) print () [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1511,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[286,610,623,722],"persona":[],"class_list":["post-1441","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-en","tag-edouard-lucas","tag-python","tag-recursive-programming","tag-tower-of-hanoi","has-thumbnail"],"_links":{"self":[{"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/posts\/1441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1441"}],"version-history":[{"count":0,"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/posts\/1441\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=\/wp\/v2\/media\/1511"}],"wp:attachment":[{"href":"https:\/\/zatizi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1441"},{"taxonomy":"persona","embeddable":true,"href":"https:\/\/zatizi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fpersona&post=1441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}