crosswords helper program

G

gg

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
 
?

=?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=

gg said:
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
words = ["BULLETIN", "BALLPARK", "BUSINESS"]
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.
 
C

Chris F.A. Johnson

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

import os
pattern = "B...E.."
wordfile = "/usr/share/dict/words"
cmd = "grep -i '\<" + pattern + "\>' " + wordfile
os.system( cmd )
 
G

gg

Chris F.A. Johnson a écrit :
import os
pattern = "B...E.."
wordfile = "/usr/share/dict/words"
cmd = "grep -i '\<" + pattern + "\>' " + wordfile
os.system( cmd )
thanks to all, that should do the trick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top