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"]
}
🚀 Installation
pip install rotate-group-words==0.3.0
📦 Usage
In Code:
from rotate-group-words import rotate_group_words
input = ["abcd", "cdab", "dabc", "bcda", "efgh", "ghfe"]
output = rotate_group_words(input)
print(output)
As standalone cli application
rgw -h
rgw -w abcd,cdab,dabc,bcda,efgh,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.dd53...4a27
[✔] Packaged and published to PyPI
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
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 rotate_group_words-0.4.6-py3-none-any.whl.
File metadata
- Download URL: rotate_group_words-0.4.6-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9117229d54b832c9c9def785f7b61ff60643d8f163f01ecaf2c3f81b0c1ab37b
|
|
| MD5 |
3a98286d7153d9c06ac350de572b581e
|
|
| BLAKE2b-256 |
328a1069d447a9b7d3b335d64d7eb9692c8112bd986371728774c2e0087e0763
|