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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file algohub-0.1.0.tar.gz.

File metadata

  • Download URL: algohub-0.1.0.tar.gz
  • Upload date:
  • Size: 50.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/22.6.0

File hashes

Hashes for algohub-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1d93e3e0cd725c3f495f36640d45a180989bc91af24852652452a231c23e568c
MD5 d7c8411cfcbb7c9db953500f126e9003
BLAKE2b-256 14156d260fff2c2f732e9bc96277dcc19f14b13ddce1b6587bf1a5c3cf067328

See more details on using hashes here.

File details

Details for the file algohub-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: algohub-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/22.6.0

File hashes

Hashes for algohub-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abbf58c42e243032af75d0d20f0bd3813f57274688fc8ec94092879e2a2d2586
MD5 39f1f3188b44d1f56a5f71decbadc44e
BLAKE2b-256 0b11f945bdb653b539c7ac8891001a523504f5ded9a96ca836732b367aa21e81

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