# A Wolfram Language facsimile of Wordle

**URL:** <https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408>\
**Category:** Staff Picks\
**Tags:** game-development, fun-and-play, mathematica, wolfram-add-ons, packages-and-paclets, ui-ux-and-ide, staff-pick, computational-humanities\
**Created:** [January 13, 2022, 9:47pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408 "2022-01-13T21:47:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 13, 2022, 9:47pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/1 "2022-01-13T21:47:44Z")

</div>

![Wordle.gif](https://global.discourse-cdn.com/wolfram/original/2X/d/d2d39150ef4bea49c0172361bab06d15cfd7fc8e.gif)

The popular game Wordle can take up a lot of your time. The author designed it so that it you can only play it once a day, thus saving us from ourselves :-).

[Wordle](https://www.powerlanguage.co.uk/wordle/)

[NYTimes article on Wordle](https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html)

But I couldn’t resist the challenge to create a version of it in Mathematica, just for fun and because I was bored this past weekend.

See the attached notebook and enjoy. Alas, since you can run it any number of times you are only to blame for yourself it you spend too much time on it.

After executing the notebook just execute

```
MWordle[Deploy]

```

to bring up the game.

A few additional comments. The notebook MWordle.nb has the option

AutoGeneratedPackage → Automatic

which causes it, when saved, to create an MWordle.m package file in its same directory.

The code in MWordle.nb is set up as a package with the context MWordle`Mwordle`

If you want to set things up so that the package gets loaded and the MWordle game is automatically launched, do the following.

Create a directory MWordleGame on your disk (The name MWordleGame can actually be whatever you wish.) And in the MWordleGame directory create a new directory called MWordle. (This name must be exactly that so that the MWordle`Mwordle` Context is property respected.) Put the MWordle.nb notebook in the MWordle dierectory, open it in Mathematica and save it so that the MWordle.m file is created in the MWordle directory. Then you can close the MWordle.nb notebook.

Now in your MWordleGame directory save a new notebook – you can call it whatever you wish, but something like LaunchMwordle.nb is a sensible choice.

In that notebook create a button with the following command:

```
CellPrint[TextCell[Button["Launch MWordle",
   Monitor[
    If[! MemberQ[$Path, NotebookDirectory[]], 
     AppendTo[$Path, NotebookDirectory[]]];
    Needs["MWordle`MWordle`"]; MWordle`MWordle`MWordle[Deploy],
    Row[{ProgressIndicator[Appearance -> "Necklace", 
       ImageSize -> Small], Spacer[5], 
      Style["Launching MWordle...", 12, Blue, 
       FontFamily -> "Arial"]}]],
   Method -> "Queued"], "Text", GeneratedCell -> False, 
  CellAutoOverwrite -> False]]

```

You now have a button in your LaunchMwordle.nb notebook which you can use any time you want to launch MWordle without having to execute the cells in the MWordle.nb notebook.

Download the actual notebook from the link at the end of this post. The following is a version here to read.

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/08c015e2-0d65-4634-bf54-4b73e518f6d5)

[MWordle.nb](https://community.wolfram.com/uploads/short-url/GkvxfbM6qDpAckZK3fGBobRExf.nb) (114 KB)

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 15, 2022, 6:17pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/2 "2022-01-15T18:17:29Z")

</div>

For those who want to cheat, I have added a cheating button that gives you the answer if you have enabled it with the checkbox next to it. But, don’t cheat! 😉

- I have updated the notebook and changed the name of the application from Wordle to MWordle. And I have added some usage messages to the functions and parameter in the notebook. Also I have added one more row to the set of possible guesses that you can make so it has the same array size as in the original web version of the game.

- Added a small update with a menu to let the user choose the part of speech to use in the puzzle: all words, nouns, verbs, or adjectives.

- I added a but more to my original post with instructions on how to set things up so that you can launch the MWordle game from a custom notebook via a simple button.

- I have updated the MWordle.nb notebook attached to this post with some additional commentary within it. The full notebook is also posted inline in the top level post. However, download the attached notebook to play with the code directly.

- I updated the main post with a screenshot of the game. Enjoy!

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 15, 2022, 6:34pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/3 "2022-01-15T18:34:32Z")

</div>

It is fun to note that, if you look at the javascript code for the web version of Wordle it is about 2000 lines of code. The facsimile in Mathematica (which admittedly does not have quite the same functionality as the original) is a bit more than 350 lines of code.

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [January 15, 2022, 8:36pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/4 "2022-01-15T20:36:09Z")

</div>

Hi David,

thanks for sharing this interesting code!

> It is fun to note that […] the web version of Wordle it is about 2000 lines of code. The facsimile in Mathematica […] is a bit more than 350 lines of code.

Exactly - the Mathematica version of code appears virtually always to be shortest. This can also be seen in an impressive way at [rosettacode.org](https://rosettacode.org), where an incredible lot of programming languages are compared.

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 16, 2022, 1:21am UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/5 "2022-01-16T01:21:12Z")

</div>

Thanks! It was fun to create on a slow Sunday evening.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [January 16, 2022, 6:31pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/6 "2022-01-16T18:31:02Z")

</div>

Wordle [post](https://mathematica.stackexchange.com/q/262191/58370) on MSE.

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 16, 2022, 7:24pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/7 "2022-01-16T19:24:03Z")

</div>

Thanks! I put a link to this post as a reply on that stackexchange post.  
Update: I did not see that you had added a link to here as a comment, but I will leave mine up as well and let the moderators choose whether to delete it. Thanks again!

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [January 19, 2022, 6:24pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/8 "2022-01-19T18:24:54Z")

</div>

![news-congrads-kkluyshnik-02-04-19.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/a/6a310c2d0904616faf4e6e148260c9f29ab9f4eb.jpeg) – you have earned _ **Featured Contributor Badge** _ ![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)  
Your exceptional post has been selected for our editorial column _ **Staff Picks** _ [http://wolfr.am/StaffPicks](http://wolfr.am/StaffPicks) and [Your Profile](http://community.wolfram.com/web/dreiss1) is now distinguished by a _ **Featured Contributor Badge** _ and is displayed on the [Featured Contributor Board](https://community.wolfram.com/people). Thank you!

---

<div class="post-metadata">

**Author:** ![dannyf](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dannyf/32/45707_2.png) [@dannyf](https://community.wolfram.com/u/dannyf)\
**Post date:** [January 21, 2022, 10:03am UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/9 "2022-01-21T10:03:28Z")

</div>

I was thinking it would be good to compute what the best starting word would be for wordle based on WordData, letter frequencies and letter position frequencies. The final word has to be a real 5-letter word as a constraint. So far I haven’t tried out any analysis though.  
Usually I use AUDIO or TEARS although it would be nice to have a top ten best words to pick from.

---

<div class="post-metadata">

**Author:** ![ahmed](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/ahmed/32/5858_2.png) [@ahmed](https://community.wolfram.com/u/ahmed)\
**Post date:** [January 21, 2022, 2:27pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/10 "2022-01-21T14:27:34Z")

</div>

I think about characters rather than words, since I am looking for the most used characters

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/a97ff511-6fec-43fd-a822-129781c0abad)

So for example if I am looking for 4-letters word, I use NEAT or something similar, but your logic is interesting and I want to try coding it.

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 21, 2022, 3:38pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/11 "2022-01-21T15:38:23Z")

</div>

There is a lot of chatter on the internet about this question (as we would expect!). Just Google “best words for Wordle” and feast your eyes. Though I prefer to leave an air of mystery to my use of the game, I can’t help but take a crack at this over my morning coffee. Here’s one approach:

[Open in Wolfram Cloud ↗](https://www.wolframcloud.com/obj/c0640cc1-c4f2-45a6-9279-a265fc8fe4fa)

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [January 21, 2022, 10:14pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/12 "2022-01-21T22:14:25Z")

</div>

Congratulations! Your post was highlighted on the Wolfram’s official social media channels. Thank you for your contribution. We are looking forward to your future posts.

- [Twitter](https://twitter.com/WolframResearch/status/1484543566512803842)

- [Facebook](https://www.facebook.com/watch/?v=1132274347547275)

---

<div class="post-metadata">

**Author:** ![dannyf](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dannyf/32/45707_2.png) [@dannyf](https://community.wolfram.com/u/dannyf)\
**Post date:** [January 24, 2022, 12:15pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/13 "2022-01-24T12:15:07Z")

</div>

Nice! It’s great to see how compact this is!

---

<div class="post-metadata">

**Author:** ![arnoudb](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arnoudb/32/41177_2.png) [@arnoudb](https://community.wolfram.com/u/arnoudb)\
**Post date:** [January 26, 2022, 5:30pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/14 "2022-01-26T17:30:43Z")

</div>

I found Wordle’s word list online and put it in a ResourceObject:

```
ResourceData[
 ResourceObject[
  CloudObject[
   "https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Data/Wordle-Word-List"]]]

```

More information here:

[https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Data/Wordle-Word-List](https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Data/Wordle-Word-List)

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 27, 2022, 2:29am UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/15 "2022-01-27T02:29:52Z")

</div>

Thanks Arnoud!

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 27, 2022, 5:00pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/16 "2022-01-27T17:00:28Z")

</div>

So this raises an interesting question about the words contained in Mathematica’s WordList.

Here are the 5 letter words that I have used from **WordList[“KnownWords”, IncludeInflections → True]**:

```
my5LetterWords =
  Module[{words},
   	words = 
    Select[WordList["KnownWords", IncludeInflections -> True], 
     StringLength[#] === 5 &];
   words = Select[words, StringMatchQ[#, LetterCharacter ..] &];
   Union[words]
   ];

```

And here are the words that Arnoud put in the **ResourceObject** :

```
wordleWords = 
  ResourceData[
   ResourceObject[
    CloudObject[
     "https://www.wolframcloud.com/obj/arnoudb/DeployedResources/Data/\
Wordle-Word-List"]]];

```

There are quite a few more in wordleWords than in my5LetterWords:

```
In[]:= Length /@ {my5LetterWords, wordleWords}

Out[]= {7766, 12972}

```

Here are how many more are in the wordle words:

```
In[]:= Length[Complement[wordleWords, my5LetterWords]]

Out[]= 6854

```

And there are some missing in the other direction:

```
In[]:= Length[Complement[my5LetterWords, wordleWords]]

Out[]= 1648

```

So, exercise for the interested student: what is going on here, and is Mathematica’s dictionary a bit too sparse?

---

<div class="post-metadata">

**Author:** ![arnoudb](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arnoudb/32/41177_2.png) [@arnoudb](https://community.wolfram.com/u/arnoudb)\
**Post date:** [January 27, 2022, 5:03pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/17 "2022-01-27T17:03:59Z")

</div>

There’s nothing wrong with the WL dictionaries, the Wordle word list seems to include a lot of “non-words”. Not sure why, but the Wordle game does accept those “non-words” on that list (I checked a few).

I’ve added a few more “solving tricks” here: [https://arnoudbuzing.medium.com/tips-and-tricks-for-solving-wordle-efficiently-28ab67a52dbf](https://arnoudbuzing.medium.com/tips-and-tricks-for-solving-wordle-efficiently-28ab67a52dbf)

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [January 27, 2022, 5:16pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/18 "2022-01-27T17:16:37Z")

</div>

It seems that both things are true?

```
In[]:= Complement[wordleWords, my5LetterWords][[-10 ;;]]

Out[]= {"zulus", "zupan", "zupas", "zuppa", "zurfs", "zuzim", \
"zygal", "zygon", "zymes", "zymic"}

```

And, for example, “zygal” is a word):

[zygal definition on Dictionary.com](https://www.dictionary.com/browse/zygal)

“Having a shape like a yoke or like the letter H”

When it comes to “zulus”, for example,

```
In[]:= DictionaryWordQ["Zulu"]

Out[]= True

```

It seems that the plural is not in the way that I retrieved the 5 letter words and that I’d need to be more careful in making sure that the various plurals are in my list (and making sure that I take care of capitalization as I do it):

```
In[]:= Pluralize["Zulu"]

Out[]= "Zulus"

```

So, I am the student that this exercise is intended for!

---

<div class="post-metadata">

**Author:** ![arnoudb](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/arnoudb/32/41177_2.png) [@arnoudb](https://community.wolfram.com/u/arnoudb)\
**Post date:** [January 27, 2022, 5:23pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/19 "2022-01-27T17:23:44Z")

</div>

Fair enough… thanks!

---

<div class="post-metadata">

**Author:** ![pbarendse](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pbarendse/32/30486_2.png) [@pbarendse](https://community.wolfram.com/u/pbarendse)\
**Post date:** [January 28, 2022, 8:47pm UTC](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408/20 "2022-01-28T20:47:38Z")

</div>

Using this, someone should really train an agent to play Wordle at a high level.

[Next page](https://community.wolfram.com/t/a-wolfram-language-facsimile-of-wordle/19408.md?page=2)
