Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for Words within a Word #38

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Look for Words within a Word #38

wants to merge 17 commits into from

Conversation

kakkarja
Copy link

Searching words that valid in English-words.txt that contain letters from the word that you search.
Example:
w = look_w("insane",6)
print(w)
['insane', 'insane', 'inanes', 'inanes', 'insane', 'insane', 'inanes', 'inanes', 'sienna', 'sienna', 'sienna', 'sienna']

Searching words that valid in English-words.txt that contain letters from the word that you search.
Update little and add comment.
look_w.py Outdated
import itertools, os

# locate your folder that contain words.txt
os.chdir("C:\\Users\\user")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this appears to be Microsoft Windows specific ... 💭

Update  on replacing variable that use in local instead of global.
Small fix, so valid missing words are collected as well
remove duplicate words
The list of words sorted.
@MysticMight
Copy link

@kakkarja @nelsonic I think means it would be better to use a more non-platform specific directory, e.g. the use of C: drive is unique to windows and not on linux, possibly the same with the directory separators, though I am not sure able them.
However after looking at your code the directory is just set by the user. An alternative is you could use the current directory of the script, though this could be swapped anyway by the user.

kakkarja and others added 6 commits March 4, 2018 11:01
Get users default (home) directory
Fix the speed. Faster result even with long words.
Checking total num against the total letters of word.
This reverts commit 1bf0341.
Saw your pull request: dwyl#38
Wanted to show you there was a simpler way to accomplish what you
were doing.  Also this solution returns words in the original case.
Stack-of-Pancakes and others added 4 commits April 29, 2018 15:24
sys imported and unused.
os only used to create cwd which is implied with open
try/except block that doesn't handle anything
json loaded to create a more expensive defaultdict
dict created just for membership testing instead of set
membership test performed by fetching key value instead of using in
Simplified version of your look_w function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants