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.

🚀 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

🛠️ 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

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

rotate_group_words-0.4.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file rotate_group_words-0.4.5-py3-none-any.whl.

File metadata

File hashes

Hashes for rotate_group_words-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 96eaf7421bdcdcc26ff2df8fd791c4c4108e879a69813627f44f653cead9593a
MD5 585ff253e4f7071d05c9531c4724672b
BLAKE2b-256 d6eff381057970d2e135c7791f7098257cad5ff909545fce2e411763643cc9bb

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