Help Optimizing Word Search

snoe case.nelson at gmail.com
Wed Jan 12 00:58:49 EST 2005


Mike,

Thanks, this worked great, and was 4x faster than my method!

Thanks everyone for replying!


The changes I made were:

!rest = ''.join([chr(i) for i in range(256) if chr(i).upper() not in
WORD])
!# a wildcard in the word means that we check all letters
!if '?' in WORD:
!    rest = ''
!translator = string.maketrans('','')

and

!            try:
!                    pool.remove( char )
!            except ValueError:
!                    # nested try to remove possible wildcard
!                    try:
!                        pool.remove( '?' )
!                    except ValueError:
!                        return False




More information about the Python-list mailing list