{"id":10191,"date":"2023-03-27T23:00:55","date_gmt":"2023-03-28T03:00:55","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=10191"},"modified":"2023-04-04T14:58:19","modified_gmt":"2023-04-04T18:58:19","slug":"three-wordle-assistants","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2023\/03\/27\/three-wordle-assistants\/","title":{"rendered":"Three Wordle Assistants"},"content":{"rendered":"<div class=\"content\"><!--introduction--><p>When I tackle a Wordle puzzle, I like to make all the key decisions myself.  My three assistants set up puzzles and suggest words when I ask for help, but I guide the actual solution. My assistants also make it possible for me to play Wordle anywhere, anytime, even when my laptop is in airplane mode. I don't need the <i>New York Times<\/i> or access to the Web.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#dacb9b49-209b-4bd4-9600-ddcbf92f222e\">Three Assistants<\/a><\/li><li><a href=\"#9a0fa3c8-2ea4-4e0d-8679-69e40f59921c\">Vocabulary<\/a><\/li><li><a href=\"#fef3bbd2-49bf-47e0-b344-69a2b844ce95\">Words<\/a><\/li><li><a href=\"#313da354-b5c6-4675-929e-3bbe89e7a74a\">Wordle<\/a><\/li><li><a href=\"#bc74a1cc-f3c3-4b86-bd1b-7a19d18b8d36\">NYT<\/a><\/li><li><a href=\"#a2a62471-6d35-4253-8c11-b0de6725afd4\">Pared Down<\/a><\/li><li><a href=\"#3634c294-6419-4ca0-9339-7a1e50630492\">Five Golds<\/a><\/li><li><a href=\"#fb298646-e9d7-4395-ba63-3e8d2607dc82\">Thanks<\/a><\/li><li><a href=\"#3daf42e9-4815-4553-9b08-c2945d557011\">Software<\/a><\/li><\/ul><\/div><h4>Three Assistants<a name=\"dacb9b49-209b-4bd4-9600-ddcbf92f222e\"><\/a><\/h4><p><tt>Wordler<\/tt>, <tt>Words<\/tt> and <tt>Wordie<\/tt> are the three assistants. <tt>Wordler<\/tt> replaces the <i>Times<\/i> by generating puzzles and evaluating responses. <tt>Words<\/tt> provides lists of possible responses. <tt>Wordie<\/tt> handles the Wordler Window and colors the letters gray, green or gold.<\/p><h4>Vocabulary<a name=\"9a0fa3c8-2ea4-4e0d-8679-69e40f59921c\"><\/a><\/h4><p><tt>Words<\/tt> has a <tt>vocabulary<\/tt> of 4665 five-letter English words. Any of them are acceptable responses. The vocabulary begins with<\/p><pre>  vocab = [ ...\r\n  \"ABEAM\" \"ABETS\" \"ABHOR\" \"ABIDE\" \"ABLED\" \"ABLER\" \"ABODE\" \"ABORT\" ...<\/pre><p>And, 584 lines later, ends with<\/p><pre>  \"ZILCH\" \"ZINCS\" \"ZINGS\" \"ZIPPY\" \"ZOMBI\" \"ZONAL\" \"ZONED\" \"ZONES\" ...\r\n  \"ZOOMS\" ];<\/pre><p>If you were to print the entire vocabulary with 40 lines per page, you would print over 100 pages of words.<\/p><h4>Words<a name=\"fef3bbd2-49bf-47e0-b344-69a2b844ce95\"><\/a><\/h4><p>It took me a long time to write the <tt>Words<\/tt> assistant, which is called whenever the Words button in the Wordle Window is clicked.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/ratio.gif\" alt=\"\"> <\/p><p><tt>Words<\/tt> is supported by a seventeen-program library of functions named <tt>Wordspq<\/tt> where <tt>p<\/tt> and <tt>q<\/tt> are nonnegative integers with <tt>p+q &lt;= 5<\/tt>. <tt>Wordspq<\/tt> finds words with <tt>p<\/tt> green letters and <tt>q<\/tt> gold letters. The programs in the <tt>Words<\/tt> library all have the same structure involving five nested <tt>for<\/tt> loops.<\/p><p>The last line of <tt>Words<\/tt> is<\/p><pre>  feval(['Words' p q],Gray,Green,GreenLoc,Gold,GoldLoc)<\/pre><p><tt>Gray<\/tt>, <tt>Green<\/tt> and <tt>Gold<\/tt> are lists of letters with specified colors and with locations <tt>GreenLoc<\/tt> and <tt>GoldLoc<\/tt>.  Locating the green letters is easy because they must be in specific slots. Locating the gold letters is tricky because each of them can be in any of several different slots.<\/p><p>For example, this situation in the NYT puzzle described below would result in a call to <tt>Words13<\/tt> with<\/p><pre>  Gray = 'AIHEC'\r\n  Green = 'T'\r\n  GreenLoc = 5\r\n  Gold = 'ROU'\r\n  GoldLoc = {[2,3],[3,4],[1,2,4]}<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/grout3.gif\" alt=\"\"> <\/p><h4>Wordle<a name=\"313da354-b5c6-4675-929e-3bbe89e7a74a\"><\/a><\/h4><p><tt>Wordle<\/tt> starts a game by choosing a secret random target from the vocabulary, or from a smaller subset about half the size. At the same time, I choose my starting word, which is usually <tt>RATIO<\/tt>.  My assistants respond with the Wordler Window and a simple keyboard.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/keybored.png\" alt=\"\"> <\/p><p>The gold <tt>O<\/tt> tells me the target contains an <tt>O<\/tt>, that it is not in position 5, and the target does not contain <tt>R<\/tt>, <tt>A<\/tt>, <tt>T<\/tt>, or <tt>I<\/tt>. I know there are hundreds of such words in the vocabulary. One of them is <tt>DEMOS<\/tt>, which I enter on the keyboard.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/demos.gif\" alt=\"\"> <\/p><p><tt>DEMOS<\/tt> happens to be a very lucky choice.  The target has an <tt>E<\/tt> in the second slot, an <tt>S<\/tt> in the last slot, <tt>M<\/tt> and <tt>O<\/tt> in the remaining slots, and no <tt>D<\/tt>. When the answer does not occur to me in a minute or two, I click the <tt>Words<\/tt> button.  The response is<\/p><pre>  MEOWS\r\n  cnt = 1<\/pre><p>So, there is only one word to choose, and it earns five greens.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/meows.gif\" alt=\"\"> <\/p><h4>NYT<a name=\"bc74a1cc-f3c3-4b86-bd1b-7a19d18b8d36\"><\/a><\/h4><p>Let's do the <i>Times<\/i> puzzle from March 23. I start with my mathematical <tt>RATIO<\/tt>. I see that the answer contains <tt>R<\/tt>, <tt>T<\/tt> and <tt>O<\/tt> and does not contain <tt>A<\/tt> or <tt>I<\/tt>.<\/p><p>I happen to remember that <tt>OTHER<\/tt> qualifies.  It does not hit any new letters, but it places additional restrictions on the ones I already have and eliminates <tt>E<\/tt> and <tt>H<\/tt>.<\/p><p><tt>Words<\/tt> now lists 37 words that I should choose from.  I pick <tt>COURT<\/tt> because it contains <tt>U<\/tt>, the only remaining vowel.<\/p><p><tt>Words<\/tt> informs me that there are only two possibilities left, <tt>TROUT<\/tt> and <tt>GROUT<\/tt>.  I pick the one without a double consonant and it is the winner.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/grout_combo.gif\" alt=\"\"> <\/p><h4>Pared Down<a name=\"a2a62471-6d35-4253-8c11-b0de6725afd4\"><\/a><\/h4><p>Here is an atypical, but instructive, example.  For this puzzle I am pleased to see <tt>Wordler<\/tt> gives <tt>RATIO<\/tt> a green <tt>A<\/tt> in position 2 and a gold <tt>R<\/tt> somewhere in positions 3 through 5.  I remember one of my favorite \"technical\" terms, <tt>PARSE<\/tt>.<\/p><p>To use a baseball metaphor, <tt>PARSE<\/tt> hits a triple and almost gets an in-the-park home run.  Now I need to ask <tt>Words<\/tt> for qualifying responses.  There are exactly two, <tt>PARED<\/tt> and <tt>PARER<\/tt>.  (Both come from the verb \"to pare\", which means to cut the outer skin off something.)<\/p><p>One of the choices has a double consonant, so I choose the other one. When it doesn't fly, the only choice left earns the five-leaf clover.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/parer_combo.gif\" alt=\"\"> <\/p><h4>Five Golds<a name=\"3634c294-6419-4ca0-9339-7a1e50630492\"><\/a><\/h4><p>How do I generate five golds?  I need the starting guess to be a <i>permutation<\/i> of the final answer.  A few moments thought suggests <tt>TAKES<\/tt> and <tt>SKATE<\/tt>.  I am sure there are other possibilities. But this one is special because <tt>STEAK<\/tt> makes it triplets. <tt>TEAKS<\/tt> would make four permutations but does not meet the \"hard mode\" restrictions.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/skate_combo.gif\" alt=\"\"> <\/p><h4>Thanks<a name=\"fb298646-e9d7-4395-ba63-3e8d2607dc82\"><\/a><\/h4><p>Over a year ago, MATLAB programs for solving Wordle puzzles were described by <a href=\"https:\/\/blogs.mathworks.com\/loren\/2022\/01\/18\/building-a-wordle-solver\/\">Adam Filion<\/a> as a guest blogger on Loren's blog and by <a href=\"https:\/\/www.youtube.com\/watch?v=bVTcQtEnOlk\">Matt Tearle<\/a> with a YouTube video.<\/p><h4>Software<a name=\"3daf42e9-4815-4553-9b08-c2945d557011\"><\/a><\/h4><p>Working on my Wordle obsession has been very interesting. I have developed some useful tools and I see forgotten five-letter words everywhere.  You can share the fun by downloading the code at <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Wordler_mzip.m\">this link<\/a> and running it yourself.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_5b2bc84c600a4474a0eabbc4d9bb6ab8() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='5b2bc84c600a4474a0eabbc4d9bb6ab8 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 5b2bc84c600a4474a0eabbc4d9bb6ab8';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2023 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_5b2bc84c600a4474a0eabbc4d9bb6ab8()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2023a<br><\/p><\/div><!--\r\n5b2bc84c600a4474a0eabbc4d9bb6ab8 ##### SOURCE BEGIN #####\r\n%% Three Wordle Assistants\r\n% When I tackle a Wordle puzzle, I like to make all the key decisions \r\n% myself.  My three assistants set up puzzles and suggest words\r\n% when I ask for help, but I guide the actual solution.\r\n% My assistants also make it possible for me to play Wordle anywhere,\r\n% anytime, even when my laptop is in airplane mode.\r\n% I don't need the _New York Times_ or access to the Web.\r\n\r\n%% Three Assistants\r\n% |Wordler|, |Words| and |Wordie| are the three assistants.\r\n% |Wordler| replaces the _Times_ by generating puzzles\r\n% and evaluating responses.\r\n% |Words| provides lists of possible responses.\r\n% |Wordie| handles the Wordler Window and colors the letters gray, \r\n% green or gold.\r\n\r\n%% Vocabulary\r\n% |Words| has a |vocabulary| of 4665 five-letter English words.\r\n% Any of them are acceptable responses.\r\n% The vocabulary begins with\r\n% \r\n%    vocab = [ ...  \r\n%    \"ABEAM\" \"ABETS\" \"ABHOR\" \"ABIDE\" \"ABLED\" \"ABLER\" \"ABODE\" \"ABORT\" ...\r\n%\r\n% And, 584 lines later, ends with\r\n%\r\n%    \"ZILCH\" \"ZINCS\" \"ZINGS\" \"ZIPPY\" \"ZOMBI\" \"ZONAL\" \"ZONED\" \"ZONES\" ...\r\n%    \"ZOOMS\" ]; \r\n%\r\n% If you were to print the entire vocabulary with 40 lines per page,\r\n% you would print over 100 pages of words.\r\n\r\n%% Words\r\n% It took me a long time to write the |Words| assistant, which is\r\n% called whenever the Words button in the Wordle Window is clicked.\r\n%\r\n% <<ratio.gif>>\r\n%\r\n% |Words| is supported by a seventeen-program library of functions\r\n% named |Wordspq| where |p| and |q| are nonnegative integers \r\n% with |p+q <= 5|.\r\n% |Wordspq| finds words with |p| green letters and |q| gold letters.\r\n% The programs in the |Words| library all have the same structure\r\n% involving five nested |for| loops.\r\n%\r\n% The last line of |Words| is\r\n%\r\n%    feval(['Words' p q],Gray,Green,GreenLoc,Gold,GoldLoc)\r\n%\r\n% |Gray|, |Green| and |Gold| are lists of letters with specified \r\n% colors and with locations |GreenLoc| and |GoldLoc|.  Locating the\r\n% green letters is easy because they must be in specific slots.\r\n% Locating the gold letters is tricky because each of them\r\n% can be in any of several different slots.\r\n%\r\n% For example, this situation in the NYT puzzle described below\r\n% would result in a call to |Words13| with\r\n%\r\n%    Gray = 'AIHEC'\r\n%    Green = 'T'\r\n%    GreenLoc = 5\r\n%    Gold = 'ROU'\r\n%    GoldLoc = {[2,3],[3,4],[1,2,4]}\r\n%\r\n% <<grout3.gif>>\r\n \r\n%% Wordle\r\n% |Wordle| starts a game by choosing a secret random target\r\n% from the vocabulary, or from a smaller subset about half the size.\r\n% At the same time, I choose my starting word, which is usually\r\n% |RATIO|.  My assistants respond with the Wordler Window\r\n% and a simple keyboard.\r\n%\r\n% <<keybored.png>>\r\n%\r\n\r\n%% \r\n% The gold |O| tells me the target contains an |O|, that it is not \r\n% in position 5, and the target does not contain |R|, |A|, |T|, or |I|.\r\n% I know there are hundreds of such words in the vocabulary.        \r\n% One of them is |DEMOS|, which I enter on the keyboard.\r\n%\r\n% <<demos.gif>>\r\n%\r\n\r\n%%\r\n% |DEMOS| happens to be a very lucky choice.  The target has an\r\n% |E| in the second slot, an |S| in the last slot, |M| and |O|\r\n% in the remaining slots, and no |D|.\r\n% When the answer does not occur to me in a minute or two,\r\n% I click the |Words| button.  The response is\r\n%\r\n%    MEOWS\r\n%    cnt = 1\r\n%\r\n% So, there is only one word to choose, and it earns five greens.\r\n%\r\n% <<meows.gif>>\r\n%\r\n\r\n%% NYT\r\n% Let's do the _Times_ puzzle from March 23.\r\n% I start with my mathematical |RATIO|.\r\n% I see that the answer contains |R|, |T| and |O| and does\r\n% not contain |A| or |I|.\r\n%\r\n% I happen to remember that |OTHER| qualifies.  It does not hit\r\n% any new letters, but it places additional restrictions on\r\n% the ones I already have and eliminates |E| and |H|.\r\n%\r\n% |Words| now lists 37 words that I should choose from.  I pick |COURT|\r\n% because it contains |U|, the only remaining vowel.\r\n%\r\n% |Words| informs me that there are only two possibilities left,\r\n% |TROUT| and |GROUT|.  I pick the one without a double consonant\r\n% and it is the winner.\r\n%\r\n% <<grout_combo.gif>>\r\n\r\n%% Pared Down\r\n% Here is an atypical, but instructive, example.  For this puzzle\r\n% I am pleased to see |Wordler| gives |RATIO| a green |A| in position 2 \r\n% and a gold |R| somewhere in positions 3 through 5.  I remember one of\r\n% my favorite \"technical\" terms, |PARSE|.\r\n%\r\n% To use a baseball metaphor, |PARSE| hits a triple and almost\r\n% gets an in-the-park home run.  Now I need to ask |Words|\r\n% for qualifying responses.  There are exactly two, |PARED| and\r\n% |PARER|.  (Both come from the verb \"to pare\", which means to cut \r\n% the outer skin off something.)\r\n%\r\n% One of the choices has a double consonant, so I choose the other\r\n% one. When it doesn't fly, the only choice left earns the\r\n% five-leaf clover.\r\n%\r\n% <<parer_combo.gif>>\r\n%\r\n\r\n%% Five Golds\r\n% How do I generate five golds?  I need the starting guess to be\r\n% a _permutation_ of the final answer.  A few moments thought\r\n% suggests |TAKES| and |SKATE|.  I am sure there are other possibilities.\r\n% But this one is special because |STEAK| makes it triplets.\r\n% |TEAKS| would make four permutations but does not meet\r\n% the \"hard mode\" restrictions.\r\n%\r\n% <<skate_combo.gif>>\r\n%\r\n\r\n%% Thanks\r\n% Over a year ago, MATLAB programs for solving Wordle puzzles \r\n% were described by\r\n% <https:\/\/blogs.mathworks.com\/loren\/2022\/01\/18\/building-a-wordle-solver\/\r\n% Adam Filion> as a guest blogger on Loren's blog and by\r\n% <https:\/\/www.youtube.com\/watch?v=bVTcQtEnOlk\r\n% Matt Tearle> with a YouTube video.\r\n\r\n%% Software\r\n% Working on my Wordle obsession has been very interesting.\r\n% I have developed some useful tools and I see forgotten five-letter\r\n% words everywhere.  You can share the fun by downloading the code at\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/Wordler_mzip.m\r\n% this link> and running it yourself.\r\n##### SOURCE END ##### 5b2bc84c600a4474a0eabbc4d9bb6ab8\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/skate_combo.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>When I tackle a Wordle puzzle, I like to make all the key decisions myself.  My three assistants set up puzzles and suggest words when I ask for help, but I guide the actual solution. My assistants also make it possible for me to play Wordle anywhere, anytime, even when my laptop is in airplane mode. I don't need the <i>New York Times<\/i> or access to the Web.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2023\/03\/27\/three-wordle-assistants\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":10218,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11,5,23,37,47,31],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10191"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=10191"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10191\/revisions"}],"predecessor-version":[{"id":10320,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10191\/revisions\/10320"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/10218"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=10191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=10191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=10191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}