Skip to main content

No project description provided

Project description

🔁 Similar String Grouper

A minimal Python tool to group similar strings based on circular rotations. It identifies words that are rotations of each other and groups them into distinct sets.

✅ What it does

Given a list of strings, it groups words that are circularly similar.

For example, "abcd" and "cdab" are grouped together because one can be rotated into the other.

Input

["abcd", "cdab", "dabc", "bcda", "efgh", "ghfe"]

Output

{
  "abcd": ["abcd", "cdab", "dabc", "bcda"],
  "efgh": ["efgh"],
  "ghfe": ["ghfe"]
}

⚙️ How it works

  • Similarity Rule: Two words are similar if a rotation of one equals the other.

  • Efficiency: The similarity check (is_similar) is optimized from O(n) to O(1).

  • Grouping: Uses a visited set to avoid duplicate processing.

  • Non-destructive: Does not mutate the input.

🛠️ Changelog & Improvements

[✔] Improved is_similar() from O(n) to O(1) by hashing normalized rotation forms.6003...5a36

[✔] Prevented duplicates using a visited set. c7ca...c4e6

[✔] Cleaned output formatting for easier reading. 118c...1b3a

[✔] 100% test coverage and CI with GitHub Actions.

[✔] Packaged and published to PyPI

🚀 Installation

pip install similar-grouper

📦 Usage

In Code:

similar-grouper

As standalone cli application

similar-grouper

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

rotate_group_words-0.3.0.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file rotate_group_words-0.3.0.tar.gz.

File metadata

  • Download URL: rotate_group_words-0.3.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for rotate_group_words-0.3.0.tar.gz
Algorithm Hash digest
SHA256 37e0a4fa3e5df1c09d1ff3eabb087287e154afce8f2484489ad3d47f1342db4c
MD5 e6abb057f8aacdc6d593df05750c527c
BLAKE2b-256 eb8f2dcc13fa6d084555ecf682a62a7bc6acec71294f65c9a19e5211f917f419

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