{"id":3874,"date":"2023-11-27T20:12:47","date_gmt":"2023-11-27T20:12:47","guid":{"rendered":"https:\/\/redfrontdoor.org\/blog\/?p=3874"},"modified":"2023-11-27T20:17:44","modified_gmt":"2023-11-27T20:17:44","slug":"searching-for-the-magic-hexagon","status":"publish","type":"post","link":"https:\/\/redfrontdoor.org\/blog\/?p=3874","title":{"rendered":"Searching for the magic hexagon"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In the same way that there are magic squares, where every row and column add up to the same sum, it turns out there is also exactly one (non-trivial) magic hexagon.  Although this solution can be worked out mostly by hand, it was interesting to explore the different approaches to writing code to search for it.  An initial unthinking version would have taken 8,000 years to run, but a series of improvements brought this down considerably:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"273\" src=\"https:\/\/redfrontdoor.org\/blog\/wp-content\/uploads\/2023\/11\/runtime-evolution-960w.png\" alt=\"Graph of improvement in run time.\" class=\"wp-image-3876\" srcset=\"https:\/\/redfrontdoor.org\/blog\/wp-content\/uploads\/2023\/11\/runtime-evolution-960w.png 960w, https:\/\/redfrontdoor.org\/blog\/wp-content\/uploads\/2023\/11\/runtime-evolution-960w-300x85.png 300w, https:\/\/redfrontdoor.org\/blog\/wp-content\/uploads\/2023\/11\/runtime-evolution-960w-768x218.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">See <a href=\"https:\/\/github.com\/bennorth\/magic-hexagon-search\">the full write-up on GitHub<\/a>.  (Code is also available there.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the same way that there are magic squares, where every row and column add up to the same sum, it turns out there is also exactly one (non-trivial) magic hexagon.  Although this solution can be worked out mostly by hand, it was interesting to explore the different approaches to writing code to search for it.<\/p>\n","protected":false},"author":2,"featured_media":3882,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","comments-off"],"_links":{"self":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3874"}],"version-history":[{"count":4,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3874\/revisions"}],"predecessor-version":[{"id":3880,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3874\/revisions\/3880"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=\/wp\/v2\/media\/3882"}],"wp:attachment":[{"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/redfrontdoor.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}