repo_name stringclasses 1
value | pr_number int64 4.12k 11.2k | pr_title stringlengths 9 107 | pr_description stringlengths 107 5.48k | author stringlengths 4 18 | date_created timestamp[ns, tz=UTC] | date_merged timestamp[ns, tz=UTC] | previous_commit stringlengths 40 40 | pr_commit stringlengths 40 40 | query stringlengths 118 5.52k | before_content stringlengths 0 7.93M | after_content stringlengths 0 7.93M | label int64 -1 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
Hill Cipher:
The 'HillCipher' class below implements the Hill Cipher algorithm which uses
modern linear algebra techniques to encode and decode text using an encryption
key matrix.
Algorithm:
Let the order of the encryption key be N (as it is a square matrix).
Your text is divided into batches of length N and con... | """
Hill Cipher:
The 'HillCipher' class below implements the Hill Cipher algorithm which uses
modern linear algebra techniques to encode and decode text using an encryption
key matrix.
Algorithm:
Let the order of the encryption key be N (as it is a square matrix).
Your text is divided into batches of length N and con... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
References: wikipedia:square free number
python/black : True
flake8 : True
"""
from __future__ import annotations
def is_square_free(factors: list[int]) -> bool:
"""
# doctest: +NORMALIZE_WHITESPACE
This functions takes a list of prime factors as input.
returns True if the factors are square free.... | """
References: wikipedia:square free number
python/black : True
flake8 : True
"""
from __future__ import annotations
def is_square_free(factors: list[int]) -> bool:
"""
# doctest: +NORMALIZE_WHITESPACE
This functions takes a list of prime factors as input.
returns True if the factors are square free.... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
Project Euler Problem 203: https://projecteuler.net/problem=203
The binomial coefficients (n k) can be arranged in triangular form, Pascal's
triangle, like this:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 ... | """
Project Euler Problem 203: https://projecteuler.net/problem=203
The binomial coefficients (n k) can be arranged in triangular form, Pascal's
triangle, like this:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 ... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
This is a pure Python implementation of the merge-insertion sort algorithm
Source: https://en.wikipedia.org/wiki/Merge-insertion_sort
For doctests run following command:
python3 -m doctest -v merge_insertion_sort.py
or
python -m doctest -v merge_insertion_sort.py
For manual testing run:
python3 merge_insertion_so... | """
This is a pure Python implementation of the merge-insertion sort algorithm
Source: https://en.wikipedia.org/wiki/Merge-insertion_sort
For doctests run following command:
python3 -m doctest -v merge_insertion_sort.py
or
python -m doctest -v merge_insertion_sort.py
For manual testing run:
python3 merge_insertion_so... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the ... | """
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the ... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
This algorithm helps you to swap cases.
User will give input and then program will perform swap cases.
In other words, convert all lowercase letters to uppercase letters and vice versa.
For example:
1. Please input sentence: Algorithm.Python@89
aLGORITHM.pYTHON@89
2. Please input sentence: github.com/mayur200
... | """
This algorithm helps you to swap cases.
User will give input and then program will perform swap cases.
In other words, convert all lowercase letters to uppercase letters and vice versa.
For example:
1. Please input sentence: Algorithm.Python@89
aLGORITHM.pYTHON@89
2. Please input sentence: github.com/mayur200
... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | import math
from timeit import timeit
def num_digits(n: int) -> int:
"""
Find the number of digits in a number.
>>> num_digits(12345)
5
>>> num_digits(123)
3
>>> num_digits(0)
1
>>> num_digits(-1)
1
>>> num_digits(-123456)
6
"""
digits = 0
n = abs(n)
wh... | import math
from timeit import timeit
def num_digits(n: int) -> int:
"""
Find the number of digits in a number.
>>> num_digits(12345)
5
>>> num_digits(123)
3
>>> num_digits(0)
1
>>> num_digits(-1)
1
>>> num_digits(-123456)
6
"""
digits = 0
n = abs(n)
wh... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | -1 | ||
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | -1 | ||
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
https://en.wikipedia.org/wiki/Lucas_number
"""
def recursive_lucas_number(n_th_number: int) -> int:
"""
Returns the nth lucas number
>>> recursive_lucas_number(1)
1
>>> recursive_lucas_number(20)
15127
>>> recursive_lucas_number(0)
2
>>> recursive_lucas_number(25)
167761
... | """
https://en.wikipedia.org/wiki/Lucas_number
"""
def recursive_lucas_number(n_th_number: int) -> int:
"""
Returns the nth lucas number
>>> recursive_lucas_number(1)
1
>>> recursive_lucas_number(20)
15127
>>> recursive_lucas_number(0)
2
>>> recursive_lucas_number(25)
167761
... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | def factorial(n: int) -> int:
"""
Calculate the factorial of a positive integer
https://en.wikipedia.org/wiki/Factorial
>>> import math
>>> all(factorial(i) == math.factorial(i) for i in range(20))
True
>>> factorial(0.1)
Traceback (most recent call last):
...
ValueError: fa... | def factorial(n: int) -> int:
"""
Calculate the factorial of a positive integer
https://en.wikipedia.org/wiki/Factorial
>>> import math
>>> all(factorial(i) == math.factorial(i) for i in range(20))
True
>>> factorial(0.1)
Traceback (most recent call last):
...
ValueError: fa... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | #!/usr/bin/env python3
"""
Created by sarathkaul on 14/11/19
Updated by lawric1 on 24/11/20
Authentication will be made via access token.
To generate your personal access token visit https://github.com/settings/tokens.
NOTE:
Never hardcode any credential information in the code. Always use an environment
file to stor... | #!/usr/bin/env python3
"""
Created by sarathkaul on 14/11/19
Updated by lawric1 on 24/11/20
Authentication will be made via access token.
To generate your personal access token visit https://github.com/settings/tokens.
NOTE:
Never hardcode any credential information in the code. Always use an environment
file to stor... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
Project Euler Problem 1: https://projecteuler.net/problem=1
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
def solution(n: int = 1000) -> int:
... | """
Project Euler Problem 1: https://projecteuler.net/problem=1
Multiples of 3 and 5
If we list all the natural numbers below 10 that are multiples of 3 or 5,
we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
def solution(n: int = 1000) -> int:
... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | #!/usr/bin/env python3
from .number_theory.prime_numbers import next_prime
class HashTable:
"""
Basic Hash Table example with open addressing and linear probing
"""
def __init__(self, size_table, charge_factor=None, lim_charge=None):
self.size_table = size_table
self.values = [None] *... | #!/usr/bin/env python3
from .number_theory.prime_numbers import next_prime
class HashTable:
"""
Basic Hash Table example with open addressing and linear probing
"""
def __init__(self, size_table, charge_factor=None, lim_charge=None):
self.size_table = size_table
self.values = [None] *... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """Uses Pythagoras theorem to calculate the distance between two points in space."""
import math
class Point:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __repr__(self) -> str:
return f"Point({self.x}, {self.y}, {self.z})"
def distance(a: Point, b: Poi... | """Uses Pythagoras theorem to calculate the distance between two points in space."""
import math
class Point:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def __repr__(self) -> str:
return f"Point({self.x}, {self.y}, {self.z})"
def distance(a: Point, b: Poi... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str:
"""
For key:hello
H E L O
A B C D
F G I J
K M N P
Q R S T
U V W X
Y Z
and map vertically
>>> mixed_keyword("college", "UNIVERSITY") # doctest: +NORMALIZE_WHITESPACE
{'A': 'C', 'B': 'A', 'C': 'I', ... | def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str:
"""
For key:hello
H E L O
A B C D
F G I J
K M N P
Q R S T
U V W X
Y Z
and map vertically
>>> mixed_keyword("college", "UNIVERSITY") # doctest: +NORMALIZE_WHITESPACE
{'A': 'C', 'B': 'A', 'C': 'I', ... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | #!/usr/bin/env python3
import importlib.util
import json
import os
import pathlib
from types import ModuleType
from typing import Dict, List
import pytest
import requests
PROJECT_EULER_DIR_PATH = pathlib.Path.cwd().joinpath("project_euler")
PROJECT_EULER_ANSWERS_PATH = pathlib.Path.cwd().joinpath(
"scripts", "pro... | #!/usr/bin/env python3
import importlib.util
import json
import os
import pathlib
from types import ModuleType
from typing import Dict, List
import pytest
import requests
PROJECT_EULER_DIR_PATH = pathlib.Path.cwd().joinpath("project_euler")
PROJECT_EULER_ANSWERS_PATH = pathlib.Path.cwd().joinpath(
"scripts", "pro... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
* Binary Exponentiation with Multiplication
* This is a method to find a*b in a time complexity of O(log b)
* This is one of the most commonly used methods of finding result of multiplication.
* Also useful in cases where solution to (a*b)%c is required,
* where a,b,c can be numbers over the computers calculation l... | """
* Binary Exponentiation with Multiplication
* This is a method to find a*b in a time complexity of O(log b)
* This is one of the most commonly used methods of finding result of multiplication.
* Also useful in cases where solution to (a*b)%c is required,
* where a,b,c can be numbers over the computers calculation l... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
https://en.wikipedia.org/wiki/Doubly_linked_list
"""
class Node:
def __init__(self, data):
self.data = data
self.previous = None
self.next = None
def __str__(self):
return f"{self.data}"
class DoublyLinkedList:
def __init__(self):
self.head = None
sel... | """
https://en.wikipedia.org/wiki/Doubly_linked_list
"""
class Node:
def __init__(self, data):
self.data = data
self.previous = None
self.next = None
def __str__(self):
return f"{self.data}"
class DoublyLinkedList:
def __init__(self):
self.head = None
sel... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | # Factorial of a number using memoization
from functools import lru_cache
@lru_cache
def factorial(num: int) -> int:
"""
>>> factorial(7)
5040
>>> factorial(-1)
Traceback (most recent call last):
...
ValueError: Number should not be negative.
>>> [factorial(i) for i in range(10)]
... | # Factorial of a number using memoization
from functools import lru_cache
@lru_cache
def factorial(num: int) -> int:
"""
>>> factorial(7)
5040
>>> factorial(-1)
Traceback (most recent call last):
...
ValueError: Number should not be negative.
>>> [factorial(i) for i in range(10)]
... | -1 |
TheAlgorithms/Python | 4,278 | fix(mypy): Fix annotations for 13 cipher algorithms | Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
ciphers/decrypt_caesar_with_chi_squared.py
ciphers/d... | dhruvmanila | 2021-03-20T09:09:15Z | 2021-03-22T06:59:51Z | 99a42f2b5821356718fb7d011ac711a6b4a63a83 | 14bcb580d55ee90614ad258ea31ef8fe4e4b5c40 | fix(mypy): Fix annotations for 13 cipher algorithms. Issue: #4052
```console
$ git diff master --name-only
ciphers/a1z26.py
ciphers/affine_cipher.py
ciphers/atbash.py
ciphers/base32.py
ciphers/base85.py
ciphers/beaufort_cipher.py
ciphers/brute_force_caesar_cipher.py
ciphers/cryptomath_module.py
c... | """
Output:
Enter an Infix Equation = a + b ^c
Symbol | Stack | Postfix
----------------------------
c | | c
^ | ^ | c
b | ^ | cb
+ | + | cb^
a | + | cb^a
| | cb^a+
a+b^c (Infix) -> +a^bc (Prefix)
"""
def infix_2_postf... | """
Output:
Enter an Infix Equation = a + b ^c
Symbol | Stack | Postfix
----------------------------
c | | c
^ | ^ | c
b | ^ | cb
+ | + | cb^
a | + | cb^a
| | cb^a+
a+b^c (Infix) -> +a^bc (Prefix)
"""
def infix_2_postf... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-executables-have-shebangs
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
exclude: |
(?x)^(
data_structures/heap/binomia... | repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-executables-have-shebangs
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
exclude: |
(?x)^(
data_structures/heap/binomia... | 1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... |
## Arithmetic Analysis
* [Bisection](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/bisection.py)
* [Gaussian Elimination](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/gaussian_elimination.py)
* [In Static Equilibrium](https://github.com/TheAlgorithms/Python/bl... |
## Arithmetic Analysis
* [Bisection](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/bisection.py)
* [Gaussian Elimination](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/gaussian_elimination.py)
* [In Static Equilibrium](https://github.com/TheAlgorithms/Python/bl... | 1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | from collections import Counter
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
data = datasets.load_iris()
X = np.array(data["data"])
y = np.array(data["target"])
classes = data["target_names"]
X_train, X_test, y_train, y_test = train_test_split(X, y)
def eucl... | from collections import Counter
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
data = datasets.load_iris()
X = np.array(data["data"])
y = np.array(data["target"])
classes = data["target_names"]
X_train, X_test, y_train, y_test = train_test_split(X, y)
def eucl... | 1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | from typing import Sequence
def evaluate_poly(poly: Sequence[float], x: float) -> float:
"""Evaluate a polynomial f(x) at specified point x and return the value.
Arguments:
poly -- the coeffiecients of a polynomial as an iterable in order of
ascending degree
x -- the point at which to eva... | from typing import Sequence
def evaluate_poly(poly: Sequence[float], x: float) -> float:
"""Evaluate a polynomial f(x) at specified point x and return the value.
Arguments:
poly -- the coefficients of a polynomial as an iterable in order of
ascending degree
x -- the point at which to eval... | 1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | # https://en.wikipedia.org/wiki/Hill_climbing
import math
class SearchProblem:
"""
An interface to define search problems.
The interface will be illustrated using the example of mathematical function.
"""
def __init__(self, x: int, y: int, step_size: int, function_to_optimize):
"""
... | # https://en.wikipedia.org/wiki/Hill_climbing
import math
class SearchProblem:
"""
An interface to define search problems.
The interface will be illustrated using the example of mathematical function.
"""
def __init__(self, x: int, y: int, step_size: int, function_to_optimize):
"""
... | 1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Isolate the Decimal part of a Number
https://stackoverflow.com/questions/3886402/how-to-get-numbers-after-decimal-point
"""
def decimal_isolate(number, digitAmount):
"""
Isolates the decimal part of a number.
If digitAmount > 0 round to that decimal place, else print the entire decimal.
>>> decim... | """
Isolate the Decimal part of a Number
https://stackoverflow.com/questions/3886402/how-to-get-numbers-after-decimal-point
"""
def decimal_isolate(number, digitAmount):
"""
Isolates the decimal part of a number.
If digitAmount > 0 round to that decimal place, else print the entire decimal.
>>> decim... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
disjoint set
Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
"""
class Node:
def __init__(self, data):
self.data = data
def make_set(x):
"""
make x as a set.
"""
# rank is the distance from x to its' parent
# root's rank is 0
x.rank = 0
x.pare... | """
disjoint set
Reference: https://en.wikipedia.org/wiki/Disjoint-set_data_structure
"""
class Node:
def __init__(self, data):
self.data = data
def make_set(x):
"""
make x as a set.
"""
# rank is the distance from x to its' parent
# root's rank is 0
x.rank = 0
x.pare... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Gaussian elimination method for solving a system of linear equations.
Gaussian elimination - https://en.wikipedia.org/wiki/Gaussian_elimination
"""
import numpy as np
def retroactive_resolution(coefficients: np.matrix, vector: np.array) -> np.array:
"""
This function performs a retroactive linear system... | """
Gaussian elimination method for solving a system of linear equations.
Gaussian elimination - https://en.wikipedia.org/wiki/Gaussian_elimination
"""
import numpy as np
def retroactive_resolution(coefficients: np.matrix, vector: np.array) -> np.array:
"""
This function performs a retroactive linear system... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
https://cp-algorithms.com/string/prefix-function.html
Prefix function Knuth–Morris–Pratt algorithm
Different algorithm than Knuth-Morris-Pratt pattern finding
E.x. Finding longest prefix which is also suffix
Time Complexity: O(n) - where n is the length of the string
"""
def prefix_function(input_string: str)... | """
https://cp-algorithms.com/string/prefix-function.html
Prefix function Knuth–Morris–Pratt algorithm
Different algorithm than Knuth-Morris-Pratt pattern finding
E.x. Finding longest prefix which is also suffix
Time Complexity: O(n) - where n is the length of the string
"""
def prefix_function(input_string: str)... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Problem 112: https://projecteuler.net/problem=112
Working from left-to-right if no digit is exceeded by the digit to its left it is
called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing
number; for example, 66420.
We shall call a pos... | """
Problem 112: https://projecteuler.net/problem=112
Working from left-to-right if no digit is exceeded by the digit to its left it is
called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing
number; for example, 66420.
We shall call a pos... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
This script demonstrates the implementation of the Softmax function.
Its a function that takes as input a vector of K real numbers, and normalizes
it into a probability distribution consisting of K probabilities proportional
to the exponentials of the input numbers. After softmax, the elements of the
vector always... | """
This script demonstrates the implementation of the Softmax function.
Its a function that takes as input a vector of K real numbers, and normalizes
it into a probability distribution consisting of K probabilities proportional
to the exponentials of the input numbers. After softmax, the elements of the
vector always... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | # Python program to implement Pigeonhole Sorting in python
# Algorithm for the pigeonhole sorting
def pigeonhole_sort(a):
"""
>>> a = [8, 3, 2, 7, 4, 6, 8]
>>> b = sorted(a) # a nondestructive sort
>>> pigeonhole_sort(a) # a destructive sort
>>> a == b
True
"""
# size of range of va... | # Python program to implement Pigeonhole Sorting in python
# Algorithm for the pigeonhole sorting
def pigeonhole_sort(a):
"""
>>> a = [8, 3, 2, 7, 4, 6, 8]
>>> b = sorted(a) # a nondestructive sort
>>> pigeonhole_sort(a) # a destructive sort
>>> a == b
True
"""
# size of range of va... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Finding the peak of a unimodal list using divide and conquer.
A unimodal array is defined as follows: array is increasing up to index p,
then decreasing afterwards. (for p >= 1)
An obvious solution can be performed in O(n),
to find the maximum of the array.
(From Kleinberg and Tardos. Algorithm Design.
Addison Wesl... | """
Finding the peak of a unimodal list using divide and conquer.
A unimodal array is defined as follows: array is increasing up to index p,
then decreasing afterwards. (for p >= 1)
An obvious solution can be performed in O(n),
to find the maximum of the array.
(From Kleinberg and Tardos. Algorithm Design.
Addison Wesl... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class LinkedList:
def __init__(self):
self.head = None
def __iter__(self):
node = self.head
while node:
yield node.data
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class LinkedList:
def __init__(self):
self.head = None
def __iter__(self):
node = self.head
while node:
yield node.data
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | def get_word_pattern(word: str) -> str:
"""
>>> get_word_pattern("pattern")
'0.1.2.2.3.4.5'
>>> get_word_pattern("word pattern")
'0.1.2.3.4.5.6.7.7.8.2.9'
>>> get_word_pattern("get word pattern")
'0.1.2.3.4.5.6.7.3.8.9.2.2.1.6.10'
"""
word = word.upper()
next_num = 0
letter_n... | def get_word_pattern(word: str) -> str:
"""
>>> get_word_pattern("pattern")
'0.1.2.2.3.4.5'
>>> get_word_pattern("word pattern")
'0.1.2.3.4.5.6.7.7.8.2.9'
>>> get_word_pattern("get word pattern")
'0.1.2.3.4.5.6.7.3.8.9.2.2.1.6.10'
"""
word = word.upper()
next_num = 0
letter_n... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | # NguyenU
def find_max(nums):
"""
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
... find_max(nums) == max(nums)
True
True
True
True
"""
max_num = nums[0]
for x in nums:
if x > max_num:
max_num = x
return max_num
def main()... | # NguyenU
def find_max(nums):
"""
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
... find_max(nums) == max(nums)
True
True
True
True
"""
max_num = nums[0]
for x in nums:
if x > max_num:
max_num = x
return max_num
def main()... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Implements a disjoint set using Lists and some added heuristics for efficiency
Union by Rank Heuristic and Path Compression
"""
class DisjointSet:
def __init__(self, set_counts: list) -> None:
"""
Initialize with a list of the number of items in each set
and with rank = 1 for each set
... | """
Implements a disjoint set using Lists and some added heuristics for efficiency
Union by Rank Heuristic and Path Compression
"""
class DisjointSet:
def __init__(self, set_counts: list) -> None:
"""
Initialize with a list of the number of items in each set
and with rank = 1 for each set
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | def remove_duplicates(key: str) -> str:
"""
Removes duplicate alphabetic characters in a keyword (letter is ignored after its
first appearance).
:param key: Keyword to use
:return: String with duplicates removed
>>> remove_duplicates('Hello World!!')
'Helo Wrd'
"""
key_no_dups =... | def remove_duplicates(key: str) -> str:
"""
Removes duplicate alphabetic characters in a keyword (letter is ignored after its
first appearance).
:param key: Keyword to use
:return: String with duplicates removed
>>> remove_duplicates('Hello World!!')
'Helo Wrd'
"""
key_no_dups =... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
This algorithm helps you to swap cases.
User will give input and then program will perform swap cases.
In other words, convert all lowercase letters to uppercase letters and vice versa.
For example:
1. Please input sentence: Algorithm.Python@89
aLGORITHM.pYTHON@89
2. Please input sentence: github.com/mayur200
... | """
This algorithm helps you to swap cases.
User will give input and then program will perform swap cases.
In other words, convert all lowercase letters to uppercase letters and vice versa.
For example:
1. Please input sentence: Algorithm.Python@89
aLGORITHM.pYTHON@89
2. Please input sentence: github.com/mayur200
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Project Euler Problem 35
https://projecteuler.net/problem=35
Problem Statement:
The number 197 is called a circular prime because all rotations of the digits:
197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73,
79, and 97.
How many circular pr... | """
Project Euler Problem 35
https://projecteuler.net/problem=35
Problem Statement:
The number 197 is called a circular prime because all rotations of the digits:
197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73,
79, and 97.
How many circular pr... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Python3 program to evaluate a prefix expression.
"""
calc = {
"+": lambda x, y: x + y,
"-": lambda x, y: x - y,
"*": lambda x, y: x * y,
"/": lambda x, y: x / y,
}
def is_operand(c):
"""
Return True if the given char c is an operand, e.g. it is a number
>>> is_operand("1")
True
... | """
Python3 program to evaluate a prefix expression.
"""
calc = {
"+": lambda x, y: x + y,
"-": lambda x, y: x - y,
"*": lambda x, y: x * y,
"/": lambda x, y: x / y,
}
def is_operand(c):
"""
Return True if the given char c is an operand, e.g. it is a number
>>> is_operand("1")
True
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Project Euler Problem 4: https://projecteuler.net/problem=4
Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
References:
-... | """
Project Euler Problem 4: https://projecteuler.net/problem=4
Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made
from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
References:
-... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
https://en.wikipedia.org/wiki/Doubly_linked_list
"""
class Node:
def __init__(self, data):
self.data = data
self.previous = None
self.next = None
def __str__(self):
return f"{self.data}"
class DoublyLinkedList:
def __init__(self):
self.head = None
sel... | """
https://en.wikipedia.org/wiki/Doubly_linked_list
"""
class Node:
def __init__(self, data):
self.data = data
self.previous = None
self.next = None
def __str__(self):
return f"{self.data}"
class DoublyLinkedList:
def __init__(self):
self.head = None
sel... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
FP-GraphMiner - A Fast Frequent Pattern Mining Algorithm for Network Graphs
A novel Frequent Pattern Graph Mining algorithm, FP-GraphMiner, that compactly
represents a set of network graphs as a Frequent Pattern Graph (or FP-Graph).
This graph can be used to efficiently mine frequent subgraphs including maximal
fr... | """
FP-GraphMiner - A Fast Frequent Pattern Mining Algorithm for Network Graphs
A novel Frequent Pattern Graph Mining algorithm, FP-GraphMiner, that compactly
represents a set of network graphs as a Frequent Pattern Graph (or FP-Graph).
This graph can be used to efficiently mine frequent subgraphs including maximal
fr... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | from sklearn import svm
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
# different functions implementing different types of SVM's
def NuSVC(train_x, train_y):
svc_NuSVC = svm.NuSVC()
svc_NuSVC.fit(train_x, train_y)
return svc_NuSVC
def Linearsvc(train_x, tra... | from sklearn import svm
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
# different functions implementing different types of SVM's
def NuSVC(train_x, train_y):
svc_NuSVC = svm.NuSVC()
svc_NuSVC.fit(train_x, train_y)
return svc_NuSVC
def Linearsvc(train_x, tra... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | import numpy as np
def power_iteration(
input_matrix: np.array, vector: np.array, error_tol=1e-12, max_iterations=100
) -> [float, np.array]:
"""
Power Iteration.
Find the largest eignevalue and corresponding eigenvector
of matrix input_matrix given a random vector in the same space.
Will work... | import numpy as np
def power_iteration(
input_matrix: np.array, vector: np.array, error_tol=1e-12, max_iterations=100
) -> [float, np.array]:
"""
Power Iteration.
Find the largest eignevalue and corresponding eigenvector
of matrix input_matrix given a random vector in the same space.
Will work... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | alphabets = [chr(i) for i in range(32, 126)]
gear_one = [i for i in range(len(alphabets))]
gear_two = [i for i in range(len(alphabets))]
gear_three = [i for i in range(len(alphabets))]
reflector = [i for i in reversed(range(len(alphabets)))]
code = []
gear_one_pos = gear_two_pos = gear_three_pos = 0
def rotator():
... | alphabets = [chr(i) for i in range(32, 126)]
gear_one = [i for i in range(len(alphabets))]
gear_two = [i for i in range(len(alphabets))]
gear_three = [i for i in range(len(alphabets))]
reflector = [i for i in reversed(range(len(alphabets)))]
code = []
gear_one_pos = gear_two_pos = gear_three_pos = 0
def rotator():
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Prim's (also known as Jarník's) algorithm is a greedy algorithm that finds a minimum
spanning tree for a weighted undirected graph. This means it finds a subset of the
edges that forms a tree that includes every vertex, where the total weight of all the
edges in the tree is minimized. The algorithm operates by buil... | """
Prim's (also known as Jarník's) algorithm is a greedy algorithm that finds a minimum
spanning tree for a weighted undirected graph. This means it finds a subset of the
edges that forms a tree that includes every vertex, where the total weight of all the
edges in the tree is minimized. The algorithm operates by buil... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | def factors_of_a_number(num: int) -> list:
"""
>>> factors_of_a_number(1)
[1]
>>> factors_of_a_number(5)
[1, 5]
>>> factors_of_a_number(24)
[1, 2, 3, 4, 6, 8, 12, 24]
>>> factors_of_a_number(-24)
[]
"""
return [i for i in range(1, num + 1) if num % i == 0]
if __name__ == "_... | def factors_of_a_number(num: int) -> list:
"""
>>> factors_of_a_number(1)
[1]
>>> factors_of_a_number(5)
[1, 5]
>>> factors_of_a_number(24)
[1, 2, 3, 4, 6, 8, 12, 24]
>>> factors_of_a_number(-24)
[]
"""
return [i for i in range(1, num + 1) if num % i == 0]
if __name__ == "_... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Champernowne's constant
Problem 40
An irrational decimal fraction is created by concatenating the positive
integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the
following expres... | """
Champernowne's constant
Problem 40
An irrational decimal fraction is created by concatenating the positive
integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the
following expres... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | PNG
IHDR ʮ sRGB gAMA a pHYs t tfx IDATx^דfו _3c46=cfSU% B{pwZkZkIA2H A2sosGXcnUߕgu9b d+dɋ\.p\./O.p\.p\_.Ȃ\.p\.
.Ȃ\.p\.
.Ȃ\.p\.
.Ȃ\.p\.
j@/p_2q!L\./'BYGmںeim¦emX~ӹeٝlز
[\ڲ?
+r... | PNG
IHDR ʮ sRGB gAMA a pHYs t tfx IDATx^דfו _3c46=cfSU% B{pwZkZkIA2H A2sosGXcnUߕgu9b d+dɋ\.p\./O.p\.p\_.Ȃ\.p\.
.Ȃ\.p\.
.Ȃ\.p\.
.Ȃ\.p\.
j@/p_2q!L\./'BYGmںeim¦emX~ӹeٝlز
[\ڲ?
+r... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Given a sorted array of integers, return indices of the two numbers such
that they add up to a specific target using the two pointers technique.
You may assume that each input would have exactly one solution, and you
may not use the same element twice.
This is an alternative solution of the two-sum problem, which... | """
Given a sorted array of integers, return indices of the two numbers such
that they add up to a specific target using the two pointers technique.
You may assume that each input would have exactly one solution, and you
may not use the same element twice.
This is an alternative solution of the two-sum problem, which... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Just to check
"""
def add(a, b):
"""
>>> add(2, 2)
4
>>> add(2, -2)
0
"""
return a + b
if __name__ == "__main__":
a = 5
b = 6
print(f"The sum of {a} + {b} is {add(a, b)}")
| """
Just to check
"""
def add(a, b):
"""
>>> add(2, 2)
4
>>> add(2, -2)
0
"""
return a + b
if __name__ == "__main__":
a = 5
b = 6
print(f"The sum of {a} + {b} is {add(a, b)}")
| -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Project Euler Problem 10: https://projecteuler.net/problem=10
Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
import math
from itertools import takewhile
from typing impor... | """
Project Euler Problem 10: https://projecteuler.net/problem=10
Summation of primes
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
import math
from itertools import takewhile
from typing impor... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | def lower(word: str) -> str:
"""
Will convert the entire string to lowecase letters
>>> lower("wow")
'wow'
>>> lower("HellZo")
'hellzo'
>>> lower("WHAT")
'what'
>>> lower("wh[]32")
'wh[]32'
>>> lower("whAT")
'what'
"""
# converting to ascii value int value and c... | def lower(word: str) -> str:
"""
Will convert the entire string to lowecase letters
>>> lower("wow")
'wow'
>>> lower("HellZo")
'hellzo'
>>> lower("WHAT")
'what'
>>> lower("wh[]32")
'wh[]32'
>>> lower("whAT")
'what'
"""
# converting to ascii value int value and c... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
python/black : true
flake8 : passed
"""
from typing import Iterator, Optional
class RedBlackTree:
"""
A Red-Black tree, which is a self-balancing BST (binary search
tree).
This tree has similar performance to AVL trees, but the balancing is
less strict, so it will perform faster for writing/de... | """
python/black : true
flake8 : passed
"""
from typing import Iterator, Optional
class RedBlackTree:
"""
A Red-Black tree, which is a self-balancing BST (binary search
tree).
This tree has similar performance to AVL trees, but the balancing is
less strict, so it will perform faster for writing/de... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | # git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
| # git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
| -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Project Euler Problem 77: https://projecteuler.net/problem=77
It is possible to write ten as the sum of primes in exactly five different ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can be written as the sum of primes in over
five thousand different ways?
"""
from fu... | """
Project Euler Problem 77: https://projecteuler.net/problem=77
It is possible to write ten as the sum of primes in exactly five different ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can be written as the sum of primes in over
five thousand different ways?
"""
from fu... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Problem 125: https://projecteuler.net/problem=125
The palindromic number 595 is interesting because it can be written as the sum
of consecutive squares: 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2.
There are exactly eleven palindromes below one-thousand that can be written as
consecutive square sums, and the sum o... | """
Problem 125: https://projecteuler.net/problem=125
The palindromic number 595 is interesting because it can be written as the sum
of consecutive squares: 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2.
There are exactly eleven palindromes below one-thousand that can be written as
consecutive square sums, and the sum o... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
Problem 81: https://projecteuler.net/problem=81
In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right,
by only moving to the right and down, is indicated in bold red and is equal to 2427.
[131] 673 234 103 18
[201] [96] [342] 965 150
630 803 [746] ... | """
Problem 81: https://projecteuler.net/problem=81
In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right,
by only moving to the right and down, is indicated in bold red and is equal to 2427.
[131] 673 234 103 18
[201] [96] [342] 965 150
630 803 [746] ... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | """
You have m types of coins available in infinite quantities
where the value of each coins is given in the array S=[S0,... Sm-1]
Can you determine number of ways of making change for n units using
the given types of coins?
https://www.hackerrank.com/challenges/coin-change/problem
"""
def dp_count(S, n):
"""
... | """
You have m types of coins available in infinite quantities
where the value of each coins is given in the array S=[S0,... Sm-1]
Can you determine number of ways of making change for n units using
the given types of coins?
https://www.hackerrank.com/challenges/coin-change/problem
"""
def dp_count(S, n):
"""
... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | -1 | ||
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | def reverse_letters(input_str: str) -> str:
"""
Reverses letters in a given string without adjusting the position of the words
>>> reverse_letters('The cat in the hat')
'ehT tac ni eht tah'
>>> reverse_letters('The quick brown fox jumped over the lazy dog.')
'ehT kciuq nworb xof depmuj revo eht ... | def reverse_letters(input_str: str) -> str:
"""
Reverses letters in a given string without adjusting the position of the words
>>> reverse_letters('The cat in the hat')
'ehT tac ni eht tah'
>>> reverse_letters('The quick brown fox jumped over the lazy dog.')
'ehT kciuq nworb xof depmuj revo eht ... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... | #!/usr/bin/env python
#
# Sort large text files in a minimum amount of memory
#
import argparse
import os
class FileSplitter:
BLOCK_FILENAME_FORMAT = "block_{0}.dat"
def __init__(self, filename):
self.filename = filename
self.block_filenames = []
def write_block(self, data, block_number... | #!/usr/bin/env python
#
# Sort large text files in a minimum amount of memory
#
import argparse
import os
class FileSplitter:
BLOCK_FILENAME_FORMAT = "block_{0}.dat"
def __init__(self, filename):
self.filename = filename
self.block_filenames = []
def write_block(self, data, block_number... | -1 |
TheAlgorithms/Python | 4,273 | Update our pre-commit dependencies | ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull re... | cclauss | 2021-03-19T09:34:15Z | 2021-03-20T05:12:17Z | b8a19ccfea0ceca9f83912aa2f5ad2c15114416a | 987567360e53da1bef786364580e9d5c6dce3fc6 | Update our pre-commit dependencies. ### **Describe your change:**
* [ ] Add an algorithm?
* [ ] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
* [ ] Update our dependencies
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/C... |