Monday, February 14, 2022

Wordle with Numbers (Part 2)

 In a previous post I explained how to use conditional highlighting in Numbers to make a Wordle-like game. It's simple enough for middle school students to create and have fun on their own and leaves open lots of extension opportunities. However, there are a few flaws in this clone: cheating can be rampant because each letter is checked immediately and individually so there's no waiting on submitting the entire word. Guesses are not limited to 6 since you can just erase a previous guess. There's no keyboard indicating which letters have been guessed or evaluated. Secret words must be manually updated, limited to one each game only, and cheaters could sneak peeks without anyone knowing.

Most of these issues could be overcome using advanced scripting like macros or visual basic (in Excel) but where's the fun in that? The whole rationale here is to clone something using a spreadsheet product to show students how formulas and spreadsheets work!

To hide the secret word a bit better and to create a word bank we can use a second sheet in Numbers, or a second worksheet in Excel/Google Sheets. Give that second sheet a name like "secret word list" and put a different word on each row, each letter separated into columns. In Column F insert the formula RAND and Numbers will assign a random number between 0 and 1.You can click the Column F menu arrow and sort by this column, thus creating a new random word to appear at the top of the list every time Numbers is open:


Now that we have a randomized word list we can reference the second table by updating our conditional highlighting rules. Back in table 1, open the rules by selecting the game area and clicking Format > Cell > Conditional Highlighting. Update the green rule first by typing in the first few letters of the second table name. When Numbers autofills the name press enter and type "$1$1" to reference the first row and double-check that "Preserve Row" is checked.
Update the remaining rules in a similar manner, referencing the correct columns and rows on the second sheet instead of the current sheet.

Forcing Numbers to check the letters only when an entire is submitted should be accomplishable by using Applescript but I haven't tried it. Also, the mobile app version of Numbers apparently has a Forms feature that creates fillable forms that may allow you to capture a word guess and then calculate the correct letters. You can also probably use text splitting formulas like =LEFT, =RIGHT, and =LEN to split the text into individual columns.

As a final thought, I'm intrigued by the possibilities of numbers in Numbers, ie cloning Nerdle. But this poses an interesting programming challenge where you not only have to provide correct integer placement clues, but also evaluate the validity of the equation! As with most programming solutions there are elegant and inelegant solutions and it's always interesting to see what students come up with.