Word squares…

May 4, 2011 | Computer Science, My Projects, Puzzles | By: Mark VandeWettering

I like to read the Programming Praxis website. Every post challenges you to write some simple programs to boost your skill, akin to finger exercises for a musical instrument. Today’s challenge was an interesting which intrigued Charles Babbage: creating word squares.

I spent about 10 minutes writing one in Python that worked rather well: here is an early version, which I augmented a bit. Running it against /usr/share/dict/words gave way too many squares, with lots of really uncommon words. I had better luck with The 12dicts word lists, which concentrate on more common words. In particular, I came up with this pair of rather pleasing order 5 squares based upon the words BRAIN WAGON.

B R A I N
R E T R O
A T L A S
I R A T E
N O S E Y
W A G O N
A G A V E
G A T O R
O V O I D
N E R D Y

Fun!

Comments

Comment from Dave Rutledge
Time 5/9/2011 at 8:17 am

Is it possible to force two words and determine if there are any results? If you managed to get NERDY at the end of both, it would be an amazing feat.

Comment from Mark VandeWettering
Time 5/9/2011 at 11:04 am

Using my smaller dictionary which holds mostly common words, I got four possibilities for BRAIN

[‘BRAIN’, ‘REEVE’, ‘AERIE’, ‘IVIED’, ‘NEEDS’]
[‘BRAIN’, ‘REEVE’, ‘AERIE’, ‘IVIED’, ‘NEEDY’]
[‘BRAIN’, ‘RETRO’, ‘ATLAS’, ‘IRATE’, ‘NOSED’]
[‘BRAIN’, ‘RETRO’, ‘ATLAS’, ‘IRATE’, ‘NOSEY’]

Using the larger dictionary (/usr/share/dict/words) I got a lot more, but most of the squares aren’t quite as pleasant as these. The ones which have “NERDY” as their last word are:

[‘BRAIN’, ‘RANCE’, ‘ANEAR’, ‘ICARD’, ‘NERDY’]
[‘BRAIN’, ‘RANCE’, ‘ANSAR’, ‘ICARD’, ‘NERDY’]
[‘BRAIN’, ‘RANCE’, ‘ANTAR’, ‘ICARD’, ‘NERDY’]
[‘BRAIN’, ‘RECCE’, ‘ACHAR’, ‘ICARD’, ‘NERDY’]
[‘BRAIN’, ‘REEVE’, ‘AEGIR’, ‘IVIED’, ‘NERDY’]
[‘BRAIN’, ‘REEVE’, ‘AESIR’, ‘IVIED’, ‘NERDY’]
[‘BRAIN’, ‘RILLE’, ‘ALAIR’, ‘ILIAD’, ‘NERDY’]