Skip to content

software-students-fall2023/3-python-package-exercise-team-dominators-1

Repository files navigation

stringmanipulate

Build Status

Description

This Python package provides a collection of string manipulation functions, including grouping anagrams, checking string inclusions, decoding strings, and finding the length of the longest substring without repeating characters.

Installation

To install this package, run the following command in your terminal:

pip install stringmanipulate

Usage

Group Anagrams

groupAnagrams(strs: List[str]) -> List[List[str]]: This function takes a list of strings and groups anagrams together. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. It returns a list where each element is a list of anagrams.

from stringmanipulate import groupAnagrams
# Example usage:
print(groupAnagrams(["bat", "tab", "eat", "tea", "tan", "nat"]))
# Output: [["bat", "tab"], ["eat", "tea"], ["tan", "nat"]]

Check Inclusion

checkInclusion(s1: str, s2: str) -> bool: This function checks if one string (s1) is a permutation of any substring of another string (s2). It returns True if any permutation of s1 can be found as a substring in s2, otherwise False.

from stringmanipulate import checkInclusion
# Example usage:
print(checkInclusion("ab", "eidbaooo"))
# Output: True

Length of Longest Substring

lengthOfLongestSubstring(s: str) -> int: This function finds the length of the longest substring without repeating characters in a given string (s). It returns the maximum length of such substrings.

from stringmanipulate import lengthOfLongestSubstring
# Example usage:
print(decodeString("3[a]2[bc]"))
# Output: "aaabcbc"

For detailed examples of how to use these commands, refer to the example script available at: Example Usage Script.

Command Line Interface Usage

The stringmanipulate package includes a command line interface (CLI) for accessing its functions directly from the command line. Here's how to use it:

  1. Ensure that stringmanipulate is installed and accessible from your command line.

  2. General format of the command:

stringmanipulate [operation] --strings [arguments] [--file filePath]

Replace [operation] with the desired function (anagrams, inclusion, longest_substring, decode_string), [arguments] with the input strings, and optionally specify a file path using --file.

  1. Operations:
  • anagrams: Group anagrams from a list of strings.
    stringmanipulate anagrams --strings "string1" "string2" "string3"
    
  • inclusion: Check if one string is a permutation of another.
    stringmanipulate inclusion --strings "firstString" "secondString"
    
  • longest_substring: Find the length of the longest substring without repeating characters.
    stringmanipulate longest_substring --strings "yourString"
    
  • decode_string: Decode a string formatted with number-letter combinations.
    stringmanipulate decode_string --strings "encodedString"
    

Additionally, you can use the --file option to specify a file from which to read the strings:

stringmanipulate [operation] --file "path/to/your/file.txt"

Contributing

To contribute to this project, please follow these steps:

  1. Clone the repository:
    git clone https://github.com/software-students-fall2023/3-python-package-exercise-team-dominators-1.git
  2. Set up a virtual environment:
    python -m venv venv
    source venv/bin/activate
  3. Install dependencies using Pipfile:
    pip install pipenv
    pipenv install
  4. Build and test the package:
    python setup.py sdist bdist_wheel
    python -m unittest discover

Team

PyPI

This package is also available on PyPI:

stringmanipulate

About

3-python-package-exercise-team-dominators-1 created by GitHub Classroom

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages