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  ʮsRGBgAMA a pHYsttfxIDATx^ד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  ʮsRGBgAMA a pHYsttfxIDATx^ד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...
JFIF``C      C  9:" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz...
JFIF``C      C  9:" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz...
-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 binary_search(lst, item, start, end): if start == end: return start if lst[start] > item else start + 1 if start > end: return start mid = (start + end) // 2 if lst[mid] < item: return binary_search(lst, item, mid + 1, end) elif lst[mid] > item: return binary_sea...
def binary_search(lst, item, start, end): if start == end: return start if lst[start] > item else start + 1 if start > end: return start mid = (start + end) // 2 if lst[mid] < item: return binary_search(lst, item, mid + 1, end) elif lst[mid] > item: return binary_sea...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
## 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,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
#!/usr/bin/env python3 from typing import Optional def decrypt_caesar_with_chi_squared( ciphertext: str, cipher_alphabet: Optional[list[str]] = None, frequencies_dict: Optional[dict[str, float]] = None, case_sensetive: bool = False, ) -> tuple[int, float, str]: """ Basic Usage ===========...
#!/usr/bin/env python3 from typing import Optional def decrypt_caesar_with_chi_squared( ciphertext: str, cipher_alphabet: Optional[list[str]] = None, frequencies_dict: Optional[dict[str, float]] = None, case_sensetive: bool = False, ) -> tuple[int, float, str]: """ Basic Usage ===========...
1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
beautifulsoup4 fake_useragent keras lxml matplotlib numpy opencv-python pandas pillow qiskit requests scikit-fuzzy sklearn statsmodels sympy tensorflow xgboost
beautifulsoup4 fake_useragent keras lxml matplotlib numpy opencv-python pandas pillow qiskit requests scikit-fuzzy sklearn statsmodels sympy tensorflow types-requests xgboost
1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
#!/usr/bin/env python3 import hashlib import importlib.util import json import os import pathlib from types import ModuleType import pytest import requests PROJECT_EULER_DIR_PATH = pathlib.Path.cwd().joinpath("project_euler") PROJECT_EULER_ANSWERS_PATH = pathlib.Path.cwd().joinpath( "scripts", "project_euler_answ...
#!/usr/bin/env python3 import hashlib import importlib.util import json import os import pathlib from types import ModuleType import pytest import requests PROJECT_EULER_DIR_PATH = pathlib.Path.cwd().joinpath("project_euler") PROJECT_EULER_ANSWERS_PATH = pathlib.Path.cwd().joinpath( "scripts", "project_euler_answ...
1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" The nested brackets problem is a problem that determines if a sequence of brackets are properly nested. A sequence of brackets s is considered properly nested if any of the following conditions are true: - s is empty - s has the form (U) or [U] or {U} where U is a properly nested string - ...
""" The nested brackets problem is a problem that determines if a sequence of brackets are properly nested. A sequence of brackets s is considered properly nested if any of the following conditions are true: - s is empty - s has the form (U) or [U] or {U} where U is a properly nested string - ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
def hex_to_bin(hex_num: str) -> int: """ Convert a hexadecimal value to its binary equivalent #https://stackoverflow.com/questions/1425493/convert-hex-to-binary Here, we have used the bitwise right shift operator: >> Shifts the bits of the number to the right and fills 0 on voids left as a result. ...
def hex_to_bin(hex_num: str) -> int: """ Convert a hexadecimal value to its binary equivalent #https://stackoverflow.com/questions/1425493/convert-hex-to-binary Here, we have used the bitwise right shift operator: >> Shifts the bits of the number to the right and fills 0 on voids left as a result. ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" This is a python3 implementation of binary search tree using recursion To run tests: python -m unittest binary_search_tree_recursive.py To run an example: python binary_search_tree_recursive.py """ import unittest from typing import Iterator, Optional class Node: def __init__(self, label: int, parent: Optio...
""" This is a python3 implementation of binary search tree using recursion To run tests: python -m unittest binary_search_tree_recursive.py To run an example: python binary_search_tree_recursive.py """ import unittest from typing import Iterator, Optional class Node: def __init__(self, label: int, parent: Optio...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
from .stack import Stack def balanced_parentheses(parentheses: str) -> bool: """Use a stack to check if a string of parentheses is balanced. >>> balanced_parentheses("([]{})") True >>> balanced_parentheses("[()]{}{[()()]()}") True >>> balanced_parentheses("[(])") False >>> balanced_par...
from .stack import Stack def balanced_parentheses(parentheses: str) -> bool: """Use a stack to check if a string of parentheses is balanced. >>> balanced_parentheses("([]{})") True >>> balanced_parentheses("[()]{}{[()()]()}") True >>> balanced_parentheses("[(])") False >>> balanced_par...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" Project Euler Problem 2: https://projecteuler.net/problem=2 Even Fibonacci Numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequenc...
""" Project Euler Problem 2: https://projecteuler.net/problem=2 Even Fibonacci Numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequenc...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" Counting Sundays Problem 19 You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twe...
""" Counting Sundays Problem 19 You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twe...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" Coin sums Problem 31: https://projecteuler.net/problem=31 In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p H...
""" Coin sums Problem 31: https://projecteuler.net/problem=31 In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation: 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p). It is possible to make £2 in the following way: 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p H...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: L...
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: L...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" 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,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
def lower(word: str) -> str: """ Will convert the entire string to lowercase 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 ...
def lower(word: str) -> str: """ Will convert the entire string to lowercase 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 ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" This is a type of divide and conquer algorithm which divides the search space into 3 parts and finds the target value based on the property of the array or list (usually monotonic property). Time Complexity : O(log3 N) Space Complexity : O(1) """ from typing import List # This is the precision for this function ...
""" This is a type of divide and conquer algorithm which divides the search space into 3 parts and finds the target value based on the property of the array or list (usually monotonic property). Time Complexity : O(log3 N) Space Complexity : O(1) """ from typing import List # This is the precision for this function ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
# https://www.geeksforgeeks.org/newton-forward-backward-interpolation/ import math from typing import List # for calculating u value def ucal(u: float, p: int) -> float: """ >>> ucal(1, 2) 0 >>> ucal(1.1, 2) 0.11000000000000011 >>> ucal(1.2, 2) 0.23999999999999994 """ temp = u ...
# https://www.geeksforgeeks.org/newton-forward-backward-interpolation/ import math from typing import List # for calculating u value def ucal(u: float, p: int) -> float: """ >>> ucal(1, 2) 0 >>> ucal(1.1, 2) 0.11000000000000011 >>> ucal(1.2, 2) 0.23999999999999994 """ temp = u ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
"""Conway's Game Of Life, Author Anurag Kumar(mailto:anuragkumarak95@gmail.com) Requirements: - numpy - random - time - matplotlib Python: - 3.5 Usage: - $python3 game_o_life <canvas_size:int> Game-Of-Life Rules: 1. Any live cell with fewer than two live neighbours dies, as if caused by under-popula...
"""Conway's Game Of Life, Author Anurag Kumar(mailto:anuragkumarak95@gmail.com) Requirements: - numpy - random - time - matplotlib Python: - 3.5 Usage: - $python3 game_o_life <canvas_size:int> Game-Of-Life Rules: 1. Any live cell with fewer than two live neighbours dies, as if caused by under-popula...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
import sys from abc import abstractmethod from collections import deque class LRUCache: """Page Replacement Algorithm, Least Recently Used (LRU) Caching.""" dq_store = object() # Cache store of keys key_reference_map = object() # References of the keys in cache _MAX_CAPACITY: int = 10 # Maximum ca...
import sys from abc import abstractmethod from collections import deque class LRUCache: """Page Replacement Algorithm, Least Recently Used (LRU) Caching.""" dq_store = object() # Cache store of keys key_reference_map = object() # References of the keys in cache _MAX_CAPACITY: int = 10 # Maximum ca...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" Multiply two numbers using Karatsuba algorithm """ def karatsuba(a, b): """ >>> karatsuba(15463, 23489) == 15463 * 23489 True >>> karatsuba(3, 9) == 3 * 9 True """ if len(str(a)) == 1 or len(str(b)) == 1: return a * b else: m1 = max(len(str(a)), len(str(b))) ...
""" Multiply two numbers using Karatsuba algorithm """ def karatsuba(a, b): """ >>> karatsuba(15463, 23489) == 15463 * 23489 True >>> karatsuba(3, 9) == 3 * 9 True """ if len(str(a)) == 1 or len(str(b)) == 1: return a * b else: m1 = max(len(str(a)), len(str(b))) ...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
import sys import webbrowser import requests from bs4 import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") url = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) res = requests.get(url, headers={"UserAgent": UserAgent().random}) # res.r...
import sys import webbrowser import requests from bs4 import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") url = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) res = requests.get(url, headers={"UserAgent": UserAgent().random}) # res.r...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
from typing import List def merge(left_half: List, right_half: List) -> List: """Helper function for mergesort. >>> left_half = [-2] >>> right_half = [-1] >>> merge(left_half, right_half) [-2, -1] >>> left_half = [1,2,3] >>> right_half = [4,5,6] >>> merge(left_half, right_half) [...
from typing import List def merge(left_half: List, right_half: List) -> List: """Helper function for mergesort. >>> left_half = [-2] >>> right_half = [-1] >>> merge(left_half, right_half) [-2, -1] >>> left_half = [1,2,3] >>> right_half = [4,5,6] >>> merge(left_half, right_half) [...
-1
TheAlgorithms/Python
4,267
Wavelet tree
### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own work -- I h...
anirudnits
2021-03-14T09:36:53Z
2021-06-08T20:49:33Z
f37d415227a21017398144a090a66f1c690705eb
b743e442599a5bf7e1cb14d9dc41bd17bde1504c
Wavelet tree. ### **Describe your change:** * [x] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my o...
""" @author: MatteoRaso """ from math import pi, sqrt from random import uniform from statistics import mean from typing import Callable def pi_estimator(iterations: int): """ An implementation of the Monte Carlo method used to find pi. 1. Draw a 2x2 square centred at (0,0). 2. Inscribe a circle withi...
""" @author: MatteoRaso """ from math import pi, sqrt from random import uniform from statistics import mean from typing import Callable def pi_estimator(iterations: int): """ An implementation of the Monte Carlo method used to find pi. 1. Draw a 2x2 square centred at (0,0). 2. Inscribe a circle withi...
-1