A simple word unscrambler using permutations
Project description
Overview
Word Unscrambler is a Python script that finds valid words from scrambled letters using permutations. It relies on pandas for word list management and itertools for generating word permutations.
Installation
Ensure Python (>=3.7) is installed and install the necessary dependency:
pip install pandas
Usage
Run the script and provide:
- A text file (words.txt) with a list of words (one per line).
- A scrambled word to unscramble.
Functions
create_dataframe_from_txt(file_path)
Reads a text file and converts it into a pandas DataFrame.
- Parameter: file_path (str) – Path to the word list file.
- Returns: DataFrame – Contains words from the file.
load_word_list_from_dataframe(df)
Converts the word column in the DataFrame into a lowercase set for quick lookup.
- Parameter: df (DataFrame) – Word list DataFrame.
- Returns: set – Unique words for easy searching.
unscramble(scrambled_word, word_list)
Generates all possible permutations of the scrambled word and checks against the word list.
- Parameters:
- scrambled_word (str) – The input scrambled word.
- word_list (set) – Set of valid words.
- Returns: set – Valid words matching permutations.
Execution Flow
- Prompt the user for the word list file path.
- Load words into a pandas DataFrame.
- Convert DataFrame into a lookup set.
- Prompt the user for scrambled input.
- Generate word permutations.
- Compare against the word list and return valid words.
Example Usage
- python unscrambler.py
- Enter file path for word list:
words.txt - Enter a scrambled word:
tap
Expected Output
Valid words for 'tap': {'tap', 'pat', 'apt'}
License
This project is licensed under The Unlicense
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unscrambler_words-1.0.0.tar.gz.
File metadata
- Download URL: unscrambler_words-1.0.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e3c92ae149bbdc1bc61c051d4b9d23db21acb70f6e32671bfb3cc5f50e92851
|
|
| MD5 |
5f6c841f97aa4e807e70638f5375b0fb
|
|
| BLAKE2b-256 |
fbcb0394a8df0099931a4f554d5af0c3a96f561b5d1fd6ab7cab90a3b3635f02
|
File details
Details for the file unscrambler_words-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unscrambler_words-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1948c98ec009aa29dc8b188c3044a3ecd9471ae112bd94255060c477d76574a
|
|
| MD5 |
25d2996ad872307b1c775b0117b2bff2
|
|
| BLAKE2b-256 |
5f037deea1e32e938dde25b8847f5adfd65e2e3fa90351b32afa0f906c84e01b
|