My wife loves word puzzles. She is amazing at them. Me? Not so much. On the other hand I love programs and programming projects that involved string manipulation. So when my wife started playing a new (to her) word puzzle – the New York Times Spelling Bee – my thoughts went to solving it programmatically.
If you are not familiar with the game, it involves seven letters for the player to make words from. Anny of the letters may be used but only letters from the list can be used. Oh, and there is one letter, shown in the center of the letters, that must be used in every word. Words much be four letters long or longer BTW.
I thought this would be a fun project to code up so I took a pass at it. I think it would be a fun project for use with students as well. It involves a number of interesting and important concepts.
For one thing, you’ll want to open and read through a text file. There are many word lists available on the interne BTW. So that part is easy. You want want to check through a list for any words that are not school appropriate (that suggests other interesting projects now that I think about it).
Looping is obvious of course. As is parsing strings to find if a given letter is or is not included in a word. One method I wrote for my solution was to build a string of letters that were not included in the list of allowed letters. I searched any possible word to make sure that no unallowed letters were part of it.
Have you tried this or a similar project? Would you use this one? If you do, let me know.
Edit: Should of known it had been done before. Useful information at Nifty Assignments.