Skip to main content

A Python package for pattern generation and sorting algorithms.

Project description

Badges

https://badge.fury.io/py/pattern-sort-package.svg https://img.shields.io/badge/License-MIT-yellow.svg

A Python package providing utilities for creating various patterns and performing sorting algorithms.

This package is designed to assist developers in generating different types of patterns for visualization and performing efficient sorting operations on datasets.

Features

  • Pattern Generation: - Triangle patterns (normal, reverse, hollow, and more). - Square patterns (normal, hollow, and checkerboard). - Pyramid and diamond patterns. - Custom pattern options.

  • Sorting Algorithms: - Bubble Sort - Merge Sort - Quick Sort - Selection Sort - Insertion Sort - Heap Sort - Shell Sort - Counting Sort - Radix Sort - Bucket Sort

Installation

Install the package using pip:

pip install pattern-sort-package

Usage

  1. Import the package: Import the Pattern and Sort classes from the package.

    from pattern_sort import Pattern, Sort
  2. Pattern Examples:

    Generate a triangle pattern:

    pattern = Pattern()
    pattern.print_triangle(5)
    
    # Output:
    # *
    # **
    # ***
    # ****
    # *****

    Generate a pyramid pattern:

    pattern.print_pyramid(5)
    
    # Output:
    #     *
    #    ***
    #   *****
    #  *******
    # *********
  3. Sorting Examples:

    Sort a list using Bubble Sort:

    sort = Sort()
    sorted_list = sort.bubble_sort([3, 2, 1])
    print(sorted_list)
    
    # Output:
    # [1, 2, 3]

    Sort a list using Merge Sort:

    sorted_list = sort.merge_sort([5, 3, 8, 6, 2])
    print(sorted_list)
    
    # Output:
    # [2, 3, 5, 6, 8]

Documentation

The Pattern and Sort classes contain the following methods:

  1. Pattern Class:

    • print_triangle(rows): Prints a triangle pattern with the given number of rows.

    • print_reverse_triangle(rows): Prints a reverse triangle pattern.

    • print_pyramid(rows): Prints a pyramid pattern.

    • print_diamond(rows): Prints a diamond pattern.

    • print_square(size): Prints a square pattern.

    • print_hollow_square(size): Prints a hollow square pattern.

    • print_right_triangle(rows): Prints a right-aligned triangle pattern.

    • print_hollow_triangle(rows): Prints a hollow triangle pattern.

    • print_checkerboard(rows, cols): Prints a checkerboard pattern.

    • print_zigzag(rows, cols): Prints a zigzag pattern.

  2. Sort Class:

    • bubble_sort(arr): Sorts a list using the Bubble Sort algorithm.

    • selection_sort(arr): Sorts a list using the Selection Sort algorithm.

    • insertion_sort(arr): Sorts a list using the Insertion Sort algorithm.

    • merge_sort(arr): Sorts a list using the Merge Sort algorithm.

    • quick_sort(arr): Sorts a list using the Quick Sort algorithm.

    • heap_sort(arr): Sorts a list using the Heap Sort algorithm.

    • shell_sort(arr): Sorts a list using the Shell Sort algorithm.

    • counting_sort(arr): Sorts a list using the Counting Sort algorithm.

    • radix_sort(arr): Sorts a list using the Radix Sort algorithm.

    • bucket_sort(arr): Sorts a list using the Bucket Sort algorithm.

Testing

The package includes unit tests to validate its functionality. You can run the tests using the following command:

python -m unittest discover tests

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

Changelog

All notable changes to this project will be documented in this file.

Version 1.0.3 (2024-12-26)

  • Added: Initial release of the package.

  • Added: Pattern class with 10 pattern-generation methods:
    • print_triangle, print_reverse_triangle, print_pyramid, print_diamond, etc.

  • Added: Sort class with 10 sorting algorithms:
    • bubble_sort, merge_sort, quick_sort, selection_sort, etc.

  • Added: Unit tests for all pattern and sorting methods.

  • Added: Comprehensive documentation in README.rst.

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

pattern_sort_package-1.0.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

pattern_sort_package-1.0.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pattern_sort_package-1.0.3.tar.gz.

File metadata

  • Download URL: pattern_sort_package-1.0.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for pattern_sort_package-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3465e8be7c68c7e6438d8b2eaa361784febc6b25596de0a42ed39a6aa9bceb24
MD5 c9a692178b4b4aef852122df7d470973
BLAKE2b-256 3aba11dab3325de550559914fd971f7f4a073f425442dc16f8c86cd85f37f4c4

See more details on using hashes here.

File details

Details for the file pattern_sort_package-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pattern_sort_package-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ee67904c20990b25d19ee1d584775b368fbd63b4530e9eef39d5fc231343fcc9
MD5 651414cde349170d8c4596a5b8eb0f1c
BLAKE2b-256 306b7b78dcda1332114efd6c5adb7d4afabf2d6ce712a14fa4a16364e18dfc44

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