Skip to main content

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.

Metadata

Release files for pattern-sort-package 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pattern-sort-package 1.0.3
File Size Uploaded
pattern_sort_package-1.0.3.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pattern-sort-package 1.0.3
File Interpreter ABI Platform
pattern_sort_package-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / pattern_sort_package-1.0.3.tar.gz

Download URL pattern_sort_package-1.0.3.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3465e8be7c68c7e6438d8b2eaa361784febc6b25596de0a42ed39a6aa9bceb24
BLAKE2b-256 checksum
How to use checksums
3aba11dab3325de550559914fd971f7f4a073f425442dc16f8c86cd85f37f4c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release files / pattern_sort_package-1.0.3-py3-none-any.whl

Download URL pattern_sort_package-1.0.3-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee67904c20990b25d19ee1d584775b368fbd63b4530e9eef39d5fc231343fcc9
BLAKE2b-256 checksum
How to use checksums
306b7b78dcda1332114efd6c5adb7d4afabf2d6ce712a14fa4a16364e18dfc44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page