473,322 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

crosswords helper program

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
Oct 12 '05 #1
3 1602
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
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.

--
Lasse Vågsæther Karlsen
http://usinglvkblog.blogspot.com/
mailto:la***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
Oct 12 '05 #2
On 2005-10-12, 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


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

--
Chris F.A. Johnson <http://cfaj.freeshell.org>
================================================== ================
Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
<http://www.torfree.net/~chris/books/cfaj/ssr.html>
Oct 12 '05 #3
gg
Chris F.A. Johnson a écrit :
On 2005-10-12, 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



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
Oct 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Ferrell | last post by:
I have a style question. I have a class with a method, m1, which needs a helper function, hf. I can put hf inside m1, or I can make it another method of the class. The only place hf should ever...
3
by: Andrew Mayo | last post by:
(note: reason for posting here; browser helper object is written in C++; C++ developers tend to know the intricacies of message handling; this looks like a Windows messaging issue) Microsoft...
0
by: Tim S. | last post by:
I have an ASP.Net app call another program, "helper.exe", on its same server. I want the helper.exe to always have a user = Administrator (as opposed to the standard aspnet_user inherited from the...
2
by: Joe Johnston | last post by:
I need a Browser Helper object written in VB. Please point me at a good example. Joe MCPx3
8
by: Joe Johnston | last post by:
I need a Browser Helper object written in VB.NET Please point me at a good example. Joe MCPx3 ~ Hoping this MSDN ng three day turnaround is true. Additional info: What is a BHO? In its...
1
by: Tran Hong Quang | last post by:
Hello, What is helper function concept? I am new to C. Thanks Tran Hong Quang
4
by: CodeLeon | last post by:
I am designing an enhanced GUI suite, and i need to know how to: * Make a user control a "helper" control, ie, one that sits at the bottom (like timer or process) * Make this control modify the...
0
by: Eric S. Johansson | last post by:
I have a module which needs to invoke a suid helper program in order to do what it needs to do. This suid helper program needs to be built and installed at the same time as the module. Is there...
6
by: mailforpr | last post by:
Suppose you have a couple of helper classes that are used by 2 client classes only. How can I hide these helper classes from other programmers? Do you think this solution is a good idea?: class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.