Skip to main content

No project description provided

Project description

Logo

⭐️ ALGOHUB - HUB OF ALGORITHMS ⭐️

All algorithms implemented in PYTHON

coverage pending
License welcome

About

This repository contains a collection of algorithms written in Python. You can find algorithms for handling numbers, including ciphers, strings and for sorting data. It is wise to learn and implement them in your projects 💯

Installation

To install this library and access algorithms, you can use pip:

pip install algohub

Documenation

Comprehensive documentation available at this link:
SPHINX DOCUMENTATION

‼️ 📄 Feel free to explore detailed README documentation for each package below 📃 ‼️

NUMBERS
MATH
STRINGS
CIPHERS
SORTING

Code Quality Checks

Pylint Rating

Measures quality of code and its adherence to coding standards and best practices.
My score:


Your code has been rated at 9.81/10 (previous run: 9.81/10, +0.00)

Mypy

Analyzes code to verify that the actual usage of variables, function arguments and return values matches the type specified in the annotations (type hints). Overall the code demonstrates high compatibility with type annotations.

Data

Except for algorithms in package there is also a data package. It consists of many useful functions for retrieving the data from user, random number generation and data validation. Feel free to explore it!

Example usage
from algohub.algorithms.data.validation import does_string_match_regex
pattern = r'^[A-Z]{3};[a-z]+;\d$'
text = "ULA;developer;2"
text_2 = "KLAUDIA;developer;3"

result = does_string_match_regex(text, pattern)
result_2 = does_string_match_regex(text_2, pattern)

print(f'Text {text} matches regex: {result}')       # True
print(f'Text {text_2} matches regex: {result_2}')   # False

Example usage of algorithms

Ciphers

from algohub.algorithms.ciphers import vigenere
# Creating an instance of Vigenère square
key = "CAT" 
vigenere_square = VigenereCipher("CAT")
# Encrypting a text
plaintext = "HOME"
encrypted_text = vigenere_square.encrypt(plaintext) 
print(f'Encrypted: {encrypted_text}')                       # JOFG
# Decrypting a text
decrypted_text = vigenere_square.decrypt(encrypted_text)
print(f'Decrypted: {decrypted_text}')                       # HOME

Strings

from algohub.algorithms.strings import string_manipulation
compressed_string = string_manipulation.compress("ABCABa")
print(f'Compression: {compressed_string}') # A2B2C1a1

Numbers

from algohub.algorithms.numbers.num_base_conversion import any_to_decimal, decimal_to_any

Decimal to binary conversion

decimal_number = 10
binary_number = decimal_to_any(decimal_number, 2)

print(f'Binary representation of {decimal_number}: {binary_number}')    # "1010"

Octal to decimal conversion

octal_number = '144'
decimal_number = any_to_decimal(octal_number, 8)

print(f'Decimal representation of {octal_number}: {decimal_number}')     # 100

OVERVIEW OF ALGORITHMS

Numbers

Digits
  • get_digits
  • sum_digits
  • move_zeroes

Divisors
  • count_divisors
  • count_common_divisors
  • sum_divisors

Primes
  • Eratosthenes Sieve
  • is_prime_basic
  • get_prime_factors
  • is_perfect_number

Number base conversion
  • decimal_to_any & any_to_decimal
  • decimal_to_hexadecimal & hexadecimal_to_decimal
  • binary_to_hexadecimal & hexadecimal_to_binary
  • binary_to_octal & octal_to_binary
  • octal_to_hexadecimal & hexadecimal_to_octal

Math

Arithmetic algorithms
  • binary_search
  • babylonian_sqrt
  • binary_exponentiation
  • iterative_factorial
  • recursive_factorial

Function algorithms
  • bisection_root
  • quadratic_roots
  • horner_evaluation
  • trapezoidal_integration
  • rectangular_integration

Geometric algorithms
  • distane_between_points
  • are_points_collinear
  • is_triangle_valid
  • is_triangle_rectangular

Strings

String analysis
  • is_anagram
  • is_pangram
  • is_palindrome
  • is_subsequence
  • count_substring_occurences
  • contains_duplicates

String manipulation
  • reverse
  • compress
  • custom_join
  • lower
  • upper

Custom string sorting
  • sort_items
  • compare_vowels_count
  • compare_chars_sum

Ciphers

  • caesar_cipher
  • vigenere_cipher
  • morse_code

Sorting

  • quick_sort
  • bubble_sort
  • merge_sort
  • selection_sort

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

algohub-0.1.0.tar.gz (50.8 kB view hashes)

Uploaded Source

Built Distribution

algohub-0.1.0-py3-none-any.whl (34.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page