Skip to main content

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:

  1. A text file (words.txt) with a list of words (one per line).
  2. 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

  1. Prompt the user for the word list file path.
  2. Load words into a pandas DataFrame.
  3. Convert DataFrame into a lookup set.
  4. Prompt the user for scrambled input.
  5. Generate word permutations.
  6. Compare against the word list and return valid words.

Example Usage

  1. python unscrambler.py
  2. Enter file path for word list:
    words.txt
  3. Enter a scrambled word:
    tap

Expected Output

Valid words for 'tap': {'tap', 'pat', 'apt'}

License

This project is licensed under The Unlicense

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unscrambler_words-1.0.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unscrambler_words-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

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

Hashes for unscrambler_words-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7e3c92ae149bbdc1bc61c051d4b9d23db21acb70f6e32671bfb3cc5f50e92851
MD5 5f6c841f97aa4e807e70638f5375b0fb
BLAKE2b-256 fbcb0394a8df0099931a4f554d5af0c3a96f561b5d1fd6ab7cab90a3b3635f02

See more details on using hashes here.

File details

Details for the file unscrambler_words-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for unscrambler_words-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1948c98ec009aa29dc8b188c3044a3ecd9471ae112bd94255060c477d76574a
MD5 25d2996ad872307b1c775b0117b2bff2
BLAKE2b-256 5f037deea1e32e938dde25b8847f5adfd65e2e3fa90351b32afa0f906c84e01b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page