crosswords helper program

Lasse Vågsæther Karlsen lasse at
Wed Oct 12 11:40:54 CEST 2005

gg wrote:
> I plan to write a program in Python in order to help me doing 
> crosswords, I was wondering if such a program already existed.
> Basically it will get the number of letters of the word (5, 10, 12...) 
> then the letters known (B in second letter, E in 5th letter...) and then 
> search in a dictionary the words matching this criteria
> Regards
> Gerard

Pretty straightforward with a regular expression:

import re
r = re.compile("^BU..N..S$", re.IGNORECASE)
for word in words:
     if r.match(word):
         print word

You would probably want to allow the user to input both some basic 
format for your program and convert it to a regular expression as well 
as input a full pattern, because then the user can have words that have 
a U or a E in the second letter, simply because he doesn't know which 
one is right yet.

Lasse Vågsæther Karlsen
mailto:lasse at
PGP KeyID: 0x2A42A1C2

More information about the Python-list mailing list