Skip to content

Python: crossword solver + dictionary file

by mat on September 3rd, 2009

This is a quick and dirty crossword solver that I wrote in python:

word=raw_input('Crossword Solver \nuse * as a wildcard: ')
f=open('dic.txt', 'r')
for line in f:
	line=line.strip()
        if len(line)==len(word):
		good=1
		pos=0
		for letter in word:
			if not letter=='*':
				if not letter==line[pos]:
					good=0
			pos+=1
		if good==1:
			print line
f.close()

Example usage:

Crossword Solver
use * as a wildcard: *arn*val
carnival

The dictionary file I used is 608.2Kb with 80,368 english words and avaliable here

3 Comments
  1. Ross permalink

    Very cool.
    However, the line “if len(line)==len(word):”
    has one too many indents.

  2. I’m gone to tell my little brother, that he should also pay a quick visit this web
    site on regular basis to get updated from newest news.

Trackbacks & Pingbacks

  1. Python Crossword Solver — www.rownet.co.uk

Leave a Reply

Note: I am currently writing my thesis so probably wont have time to reply to your comment
Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS