{"id":315,"date":"2013-11-07T17:49:01","date_gmt":"2013-11-08T01:49:01","guid":{"rendered":"http:\/\/alexboisvert.com\/musings\/?p=315"},"modified":"2013-11-12T10:14:04","modified_gmt":"2013-11-12T18:14:04","slug":"npr-puzzle-for-2013-11-03-a-perl-solution","status":"publish","type":"post","link":"https:\/\/alexboisvert.com\/musings\/2013\/11\/07\/npr-puzzle-for-2013-11-03-a-perl-solution\/","title":{"rendered":"NPR Puzzle for 2013-11-03: a perl solution"},"content":{"rendered":"<p><strong>Edit:<\/strong> <em>This post has been updated with a better version of the code.<\/em><\/p>\n<p>Here&#8217;s <a href=\"http:\/\/www.npr.org\/2013\/11\/03\/242440136\/regardless-of-the-answer-stay-staid\">the most recent NPR puzzle<\/a>:<\/p>\n<blockquote><p>A famous actress and a famous director share the same last name, although they are unrelated. The first name of one of these is a classic musical. The first name of the other is an anagram of a classic musical. Who are they?<\/p><\/blockquote>\n<p>Yes, this is an easy one.  But hey, let&#8217;s see if a computer can solve it anyway &#8230;<br \/>\n<!--more--><br \/>\nSo what&#8217;s the strategy, if you were solving this without a computer?<\/p>\n<ol>\n<li>Come up with some famous musicals that can also be a first name\n<li>Think of a famous director\/actress with that first name\n<li>Think of another famous person with the same last name and see if it anagrams to a musical.\n<\/ol>\n<p>Well, these steps are clearly achievable with a computer.<\/p>\n<ol>\n<li>Get a list of famous musicals.  In the solution here, we&#8217;ll take Wikipedia titles under the &#8220;Broadway musicals&#8221; category.  Even though there are probably other ways to get such a list, I like this one because the method extends to just about any other category.\n<li>Go through a <a href=\"http:\/\/crosswordnexus.com\/downloads\/FamousNames.txt\">list of famous names<\/a> and see if any of them have a first name that&#8217;s the same as a musical.\n<li>For each last name from the previous step, find all associated first names that anagram to a musical in the list.  You can just sort the first names and the musicals to check for anagrams; I prefer to convert the words to a hash, because math.\n<\/ol>\n<p>Easy!  <a href=\"http:\/\/pastebin.com\/asQEhdfJ\">I wrote up a solution and posted it here.<\/a>  If you restrict yourself to names with a score above 90, you get the following:<\/p>\n<blockquote><p>napoleon and selim iii => smile<br \/>\noliver and emma stone => mame<\/p><\/blockquote>\n<p>I didn&#8217;t know of Selim III, but that&#8217;s on me, as he appears to be <a href=\"http:\/\/en.wikipedia.org\/wiki\/Selim_III\">a bit of a big deal.<\/a>  The musicals &#8220;Napoleon&#8221; and &#8220;Smile&#8221; &#8230; <a href=\"http:\/\/en.wikipedia.org\/wiki\/Smile_%28musical%29\">eh, not so much<\/a>.  The other answer is better, and is of course the intended answer to the original problem.<\/p>\n<p><em>In case you&#8217;re curious, Oliver Stone scores 100 in the Famous Names list, while Emma only scores 98.  That seems about right.  Sharon, whom I tried for several minutes to anagram into a musical, is also at 98.<\/em><\/p>\n<p>If you remove the score restriction, you get a few other answers, including <a href=\"https:\/\/twitter.com\/al_ex_b\/status\/398228615063543808\">the one I tweeted about recently<\/a>.  The first answer is clearly the best, though.<\/p>\n<p>Are there any other clear generalizations to this question that we could get a good answer to with the script?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Edit: This post has been updated with a better version of the code. Here&#8217;s the most recent NPR puzzle: A famous actress and a famous director share the same last name, although they are unrelated. The first name of one &hellip; <a href=\"https:\/\/alexboisvert.com\/musings\/2013\/11\/07\/npr-puzzle-for-2013-11-03-a-perl-solution\/\">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":[3,5],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-coding","category-puzzles"],"_links":{"self":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/315","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=315"}],"version-history":[{"count":6,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":331,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/posts\/315\/revisions\/331"}],"wp:attachment":[{"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexboisvert.com\/musings\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}