{"id":238,"date":"2012-09-07T00:47:43","date_gmt":"2012-09-07T00:47:43","guid":{"rendered":"http:\/\/alexboisvert.com\/musings\/?p=238"},"modified":"2012-09-07T00:47:43","modified_gmt":"2012-09-07T00:47:43","slug":"anagram-word-ladders","status":"publish","type":"post","link":"https:\/\/alexboisvert.com\/musings\/2012\/09\/07\/anagram-word-ladders\/","title":{"rendered":"Anagram Word Ladders"},"content":{"rendered":"<p><a href=\"http:\/\/www.npr.org\/2012\/09\/02\/160444345\/an-amusing-set-of-19th-century-riddles\">The most recent NPR puzzle was an anagram word ladder<\/a>, and I thought I&#8217;d try my hand at finding a solution in Perl*.  Well, I did it and I&#8217;d like to share the code with anyone who&#8217;s interested.  <a href=\"http:\/\/pastebin.com\/ySVPSvLj\">You can find it here.<\/a><\/p>\n<p><em>* Remember how I was <a href=\"http:\/\/alexboisvert.com\/musings\/2011\/05\/19\/deprecated-perl\/\">going to be leaving Perl<\/a> a while back? Yeah, that never happened.<\/em><\/p>\n<p>As far as I know, this is the first coded-up solution to anagram word ladders publicly available.  It relies on a breadth-first search, which has a few advantages: (1) it is guaranteed to find a solution if one exists, and (2) it will actually find <strong>all<\/strong> of the shortest solutions, up to anagrams of intermediate words.  There were tons of short solutions to the AUTUMN-LEAVES puzzle from NPR, and I won&#8217;t post them here.  But just as an example, here it is turning NINETY to EIGHTH (an old puzzle from Merl Reagle):<\/p>\n<pre>\r\nNINETY WITNEY* WHITEY EIGHTY EIGHTH\r\nNINETY INTONE TOEING HOGTIE EIGHTH\r\nNINETY WITNEY TEWING* WEIGHT EIGHTH\r\nNINETY WITNEY WHITEY WEIGHT EIGHTH\r\nNINETY WITNEY WHITEY EIGHTY EIGHTH\r\nNINETY TYNING NIGHTY EIGHTY EIGHTH\r\nNINETY NITERY* HINTER HITHER EIGHTH\r\nNINETY NITERY HINTER HITHER EIGHTH\r\nNINETY WITNEY WHITEN WEIGHT EIGHTH\r\nNINETY INTONE ETHION HOGTIE EIGHTH\r\nNINETY SENNIT THEINS EIGHTS EIGHTH\r\nNINETY INTERN HINTER HITHER EIGHTH\r\nNINETY TYNING* NIGHTY EIGHTY EIGHTH\r\nNINETY WITNEY WHITEN WEIGHT EIGHTH\r\nNINETY SENNIT INGEST EIGHTS EIGHTH\r\n<\/pre>\n<p><em>*Boy, does the Scrabble dictionary have some terrible words in it. Yecch.<\/em><\/p>\n<p>I don&#8217;t know if anyone will find this code useful in any way, but there it is.  And man, if someone wants to write it in C\/C++ so it could run faster, that would be excellent.  Anyway, enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The most recent NPR puzzle was an anagram word ladder, and I thought I&#8217;d try my hand at finding a solution in Perl*. Well, I did it and I&#8217;d like to share the code with anyone who&#8217;s interested. You can &hellip; <a href=\"https:\/\/alexboisvert.com\/musings\/2012\/09\/07\/anagram-word-ladders\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-238","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/comments?post=238"}],"version-history":[{"count":3,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/238\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}