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,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...
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KAT...
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KAT...
-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 base64 def main() -> None: inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __na...
import base64 def main() -> None: inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __na...
-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...
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure p...
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure p...
-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...
""" Python program for Bitonic Sort. Note that this program works only when size of input is a power of 2. """ from typing import List def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None: """Compare the value at given index1 and index2 of the array and swap them as per the g...
""" Python program for Bitonic Sort. Note that this program works only when size of input is a power of 2. """ from typing import List def comp_and_swap(array: List[int], index1: int, index2: int, direction: int) -> None: """Compare the value at given index1 and index2 of the array and swap them as per the g...
-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...
"""Implementation of Basic Math in Python.""" import math def prime_factors(n: int) -> list: """Find Prime Factors. >>> prime_factors(100) [2, 2, 5, 5] """ pf = [] while n % 2 == 0: pf.append(2) n = int(n / 2) for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i...
"""Implementation of Basic Math in Python.""" import math def prime_factors(n: int) -> list: """Find Prime Factors. >>> prime_factors(100) [2, 2, 5, 5] """ pf = [] while n % 2 == 0: pf.append(2) n = int(n / 2) for i in range(3, int(math.sqrt(n)) + 1, 2): while n % i...
-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...
# Primality Testing with the Rabin-Miller Algorithm import random def rabinMiller(num: int) -> bool: s = num - 1 t = 0 while s % 2 == 0: s = s // 2 t += 1 for trials in range(5): a = random.randrange(2, num - 1) v = pow(a, s, num) if v != 1: i = 0...
# Primality Testing with the Rabin-Miller Algorithm import random def rabinMiller(num: int) -> bool: s = num - 1 t = 0 while s % 2 == 0: s = s // 2 t += 1 for trials in range(5): a = random.randrange(2, num - 1) v = pow(a, s, num) if v != 1: i = 0...
-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 074: https://projecteuler.net/problem=74 Starting from any positive integer number it is possible to attain another one summing the factorial of its digits. Repeating this step, we can build chains of numbers. It is not difficult to prove that EVERY starting number wi...
""" Project Euler Problem 074: https://projecteuler.net/problem=74 Starting from any positive integer number it is possible to attain another one summing the factorial of its digits. Repeating this step, we can build chains of numbers. It is not difficult to prove that EVERY starting number wi...
-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...
""" Given a partially filled 9×9 2D array, the objective is to fill a 9×9 square grid with digits numbered 1 to 9, so that every row, column, and and each of the nine 3×3 sub-grids contains all of the digits. This can be solved using Backtracking and is similar to n-queens. We check to see if a cell is safe or not and...
""" Given a partially filled 9×9 2D array, the objective is to fill a 9×9 square grid with digits numbered 1 to 9, so that every row, column, and and each of the nine 3×3 sub-grids contains all of the digits. This can be solved using Backtracking and is similar to n-queens. We check to see if a cell is safe or not 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...
import math def rearrange(bitString32): """[summary] Regroups the given binary string. Arguments: bitString32 {[string]} -- [32 bit binary] Raises: ValueError -- [if the given string not are 32 bit binary string] Returns: [string] -- [32 bit binary string] >>> rearrange(...
import math def rearrange(bitString32): """[summary] Regroups the given binary string. Arguments: bitString32 {[string]} -- [32 bit binary] Raises: ValueError -- [if the given string not are 32 bit binary string] Returns: [string] -- [32 bit binary string] >>> rearrange(...
-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 """ A naive recursive implementation of 0-1 Knapsack Problem https://en.wikipedia.org/wiki/Knapsack_problem """ def knapsack(capacity: int, weights: List[int], values: List[int], counter: int) -> int: """ Returns the maximum value that can be put in a knapsack of a capacity cap, ...
from typing import List """ A naive recursive implementation of 0-1 Knapsack Problem https://en.wikipedia.org/wiki/Knapsack_problem """ def knapsack(capacity: int, weights: List[int], values: List[int], counter: int) -> int: """ Returns the maximum value that can be put in a knapsack of a capacity cap, ...
-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...
""" In a multi-threaded download, this algorithm could be used to provide each worker thread with a block of non-overlapping bytes to download. For example: for i in allocation_list: requests.get(url,headers={'Range':f'bytes={i}'}) """ from __future__ import annotations def allocation_num(number_of_bytes:...
""" In a multi-threaded download, this algorithm could be used to provide each worker thread with a block of non-overlapping bytes to download. For example: for i in allocation_list: requests.get(url,headers={'Range':f'bytes={i}'}) """ from __future__ import annotations def allocation_num(number_of_bytes:...
-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__ = "Tobias Carryer" from time import time class LinearCongruentialGenerator: """ A pseudorandom number generator. """ def __init__(self, multiplier, increment, modulo, seed=int(time())): """ These parameters are saved and used when nextNumber() is called. modulo is...
__author__ = "Tobias Carryer" from time import time class LinearCongruentialGenerator: """ A pseudorandom number generator. """ def __init__(self, multiplier, increment, modulo, seed=int(time())): """ These parameters are saved and used when nextNumber() is called. modulo is...
-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://en.wikipedia.org/wiki/Continuous_knapsack_problem # https://www.guru99.com/fractional-knapsack-problem-greedy.html # https://medium.com/walkinthecode/greedy-algorithm-fractional-knapsack-problem-9aba1daecc93 from __future__ import annotations def fractional_knapsack( value: list[int], weight: list[int]...
# https://en.wikipedia.org/wiki/Continuous_knapsack_problem # https://www.guru99.com/fractional-knapsack-problem-greedy.html # https://medium.com/walkinthecode/greedy-algorithm-fractional-knapsack-problem-9aba1daecc93 from __future__ import annotations def fractional_knapsack( value: list[int], weight: list[int]...
-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...
# Video Explanation: https://www.youtube.com/watch?v=6w60Zi1NtL8&feature=emb_logo from __future__ import annotations def maximum_non_adjacent_sum(nums: list[int]) -> int: """ Find the maximum non-adjacent sum of the integers in the nums input list >>> print(maximum_non_adjacent_sum([1, 2, 3])) 4 ...
# Video Explanation: https://www.youtube.com/watch?v=6w60Zi1NtL8&feature=emb_logo from __future__ import annotations def maximum_non_adjacent_sum(nums: list[int]) -> int: """ Find the maximum non-adjacent sum of the integers in the nums input list >>> print(maximum_non_adjacent_sum([1, 2, 3])) 4 ...
-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...
""" 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,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...
# Minimum cut on Ford_Fulkerson algorithm. test_graph = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def BFS(graph, s, t, parent): # Return True if there is node that has not iterated. visited = [Fals...
# Minimum cut on Ford_Fulkerson algorithm. test_graph = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def BFS(graph, s, t, parent): # Return True if there is node that has not iterated. visited = [Fals...
-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,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple def electric_power(voltage: float, current: float, power: float) -> float: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. examples are below: ...
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple from typing import Tuple def electric_power(voltage: float, current: float, power: float) -> Tuple: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. ...
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# https://en.wikipedia.org/wiki/Ohm%27s_law def ohms_law(voltage: float, current: float, resistance: float) -> float: """ Apply Ohm's Law, on any two given electrical values, which can be voltage, current, and resistance, and then in a Python dict return name/value pair of the zero value. >>> ohms_la...
# https://en.wikipedia.org/wiki/Ohm%27s_law from typing import Dict def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, float]: """ Apply Ohm's Law, on any two given electrical values, which can be voltage, current, and resistance, and then in a Python dict return name/value pair ...
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# Implementation of First Come First Served scheduling algorithm # In this Algorithm we just care about the order that the processes arrived # without carring about their duration time # https://en.wikipedia.org/wiki/Scheduling_(computing)#First_come,_first_served from typing import List def calculate_waiting_times(d...
# Implementation of First Come First Served scheduling algorithm # In this Algorithm we just care about the order that the processes arrived # without carring about their duration time # https://en.wikipedia.org/wiki/Scheduling_(computing)#First_come,_first_served from typing import List def calculate_waiting_times(d...
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Round Robin is a scheduling algorithm. In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ from statistics import mean from typing import List def calculate_waiting_times(burst_times: List[int]) -> List[int]: """ Calculate the...
""" Round Robin is a scheduling algorithm. In Round Robin each process is assigned a fixed time slot in a cyclic way. https://en.wikipedia.org/wiki/Round-robin_scheduling """ from statistics import mean from typing import List def calculate_waiting_times(burst_times: List[int]) -> List[int]: """ Calculate the...
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from typing import List import pandas as pd def calculate_waitingtime( arrival_time: List[int], burst_time: List[int], no_of_processes: int ) -> List[int]: """ Calculate the waiting time o...
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from typing import List import pandas as pd def calculate_waitingtime( arrival_time: List[int], burst_time: List[int], no_of_processes: int ) -> List[int]: """ Calculate the waiting time o...
1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" A Queue using a linked list like structure """ from typing import Any class Node: def __init__(self, data: Any) -> None: self.data = data self.next = None def __str__(self) -> str: return f"{self.data}" class LinkedQueue: """ >>> queue = LinkedQueue() >>> queue.is_em...
""" A Queue using a linked list like structure """ from typing import Any class Node: def __init__(self, data: Any) -> None: self.data = data self.next = None def __str__(self) -> str: return f"{self.data}" class LinkedQueue: """ >>> queue = LinkedQueue() >>> queue.is_em...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" developed by: markmelnic original repo: https://github.com/markmelnic/Scoring-Algorithm Analyse data using a range based percentual proximity algorithm and calculate the linear maximum likelihood estimation. The basic principle is that all values supplied will be broken down to a range from 0 to 1 and each column'...
""" developed by: markmelnic original repo: https://github.com/markmelnic/Scoring-Algorithm Analyse data using a range based percentual proximity algorithm and calculate the linear maximum likelihood estimation. The basic principle is that all values supplied will be broken down to a range from 0 to 1 and each column'...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
#!/usr/bin/env python3 """ Build a simple bare-minimum quantum circuit that starts with a single qubit (by default, in state 0) and inverts it. Run the experiment 1000 times and print the total count of the states finally observed. Qiskit Docs: https://qiskit.org/documentation/getting_started.html """ import qiskit as...
#!/usr/bin/env python3 """ Build a simple bare-minimum quantum circuit that starts with a single qubit (by default, in state 0) and inverts it. Run the experiment 1000 times and print the total count of the states finally observed. Qiskit Docs: https://qiskit.org/documentation/getting_started.html """ import qiskit as...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
import operator def strand_sort(arr: list, reverse: bool = False, solution: list = None) -> list: """ Strand sort implementation source: https://en.wikipedia.org/wiki/Strand_sort :param arr: Unordered input list :param reverse: Descent ordering flag :param solution: Ordered items container ...
import operator def strand_sort(arr: list, reverse: bool = False, solution: list = None) -> list: """ Strand sort implementation source: https://en.wikipedia.org/wiki/Strand_sort :param arr: Unordered input list :param reverse: Descent ordering flag :param solution: Ordered items container ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Project Euler Problem 7: https://projecteuler.net/problem=7 10001st prime By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? References: - https://en.wikipedia.org/wiki/Prime_number """ def isprime(number: int) -> bool: ...
""" Project Euler Problem 7: https://projecteuler.net/problem=7 10001st prime By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? References: - https://en.wikipedia.org/wiki/Prime_number """ def isprime(number: int) -> bool: ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# flake8: noqa """ This is pure Python implementation of tree traversal algorithms """ from __future__ import annotations import queue class TreeNode: def __init__(self, data): self.data = data self.right = None self.left = None def build_tree(): print("\n********Press N to stop en...
# flake8: noqa """ This is pure Python implementation of tree traversal algorithms """ from __future__ import annotations import queue class TreeNode: def __init__(self, data): self.data = data self.right = None self.left = None def build_tree(): print("\n********Press N to stop en...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance def lamberts_ellipsoidal_distance( lat1: float, lon1: float, lat2: float, lon2: float ) -> float: """ Calculate the shortest distance along the surface of an ellipsoid between two points on the surface o...
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance def lamberts_ellipsoidal_distance( lat1: float, lon1: float, lat2: float, lon2: float ) -> float: """ Calculate the shortest distance along the surface of an ellipsoid between two points on the surface o...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" 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,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ import math def isprime(num: int) ...
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ import math def isprime(num: int) ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
def search(list_data: list, key: int, left: int = 0, right: int = 0) -> int: """ Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched :param key: the key to be searched :param left: the index of first element :param right: the index of las...
def search(list_data: list, key: int, left: int = 0, right: int = 0) -> int: """ Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched :param key: the key to be searched :param left: the index of first element :param right: the index of las...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr):...
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr):...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
#!/usr/bin/env python3 import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths filepaths = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" upper_files = [file for file in filepaths if file != file.lower()] if uppe...
#!/usr/bin/env python3 import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths filepaths = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" upper_files = [file for file in filepaths if file != file.lower()] if uppe...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" 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,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Problem 16: https://projecteuler.net/problem=16 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def solution(power: int = 1000) -> int: """Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> s...
""" Problem 16: https://projecteuler.net/problem=16 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? """ def solution(power: int = 1000) -> int: """Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> s...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) ...
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that only the integer weights 0-1 knapsack problem is solvable using dynamic programming. """ def MF_knapsack(i, wt, val, j): """ This code involves the concept of memor...
""" Given weights and values of n items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. Note that only the integer weights 0-1 knapsack problem is solvable using dynamic programming. """ def MF_knapsack(i, wt, val, j): """ This code involves the concept of memor...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" This is a pure Python implementation of the merge-insertion sort algorithm Source: https://en.wikipedia.org/wiki/Graham_scan For doctests run following command: python3 -m doctest -v graham_scan.py """ from __future__ import annotations from collections import deque from enum import Enum from math import atan2, ...
""" This is a pure Python implementation of the merge-insertion sort algorithm Source: https://en.wikipedia.org/wiki/Graham_scan For doctests run following command: python3 -m doctest -v graham_scan.py """ from __future__ import annotations from collections import deque from enum import Enum from math import atan2, ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
"""Implementation of GradientBoostingRegressor in sklearn using the boston dataset which is very popular for regression problem to predict house price. """ import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_boston from sklearn.ensemble import GradientBoostingRegressor from skle...
"""Implementation of GradientBoostingRegressor in sklearn using the boston dataset which is very popular for regression problem to predict house price. """ import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_boston from sklearn.ensemble import GradientBoostingRegressor from skle...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" https://en.wikipedia.org/wiki/Atbash """ import string def atbash_slow(sequence: str) -> str: """ >>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC' """ output = "" for i in sequence: extract = ord(i) if 65 <= extract <= 90: o...
""" https://en.wikipedia.org/wiki/Atbash """ import string def atbash_slow(sequence: str) -> str: """ >>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC' """ output = "" for i in sequence: extract = ord(i) if 65 <= extract <= 90: o...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We t...
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We t...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# @Author : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width...
# @Author : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Project Euler Problem 91: https://projecteuler.net/problem=91 The points P (x1, y1) and Q (x2, y2) are plotted at integer coordinates and are joined to the origin, O(0,0), to form ΔOPQ.  There are exactly fourteen triangles containing a right angle that can be formed when each coordinate lies between 0 and 2 incl...
""" Project Euler Problem 91: https://projecteuler.net/problem=91 The points P (x1, y1) and Q (x2, y2) are plotted at integer coordinates and are joined to the origin, O(0,0), to form ΔOPQ.  There are exactly fourteen triangles containing a right angle that can be formed when each coordinate lies between 0 and 2 incl...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# Author: Abhijeeth S import math def res(x, y): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.log10(x) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: return 1 # any number rais...
# Author: Abhijeeth S import math def res(x, y): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.log10(x) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0: return 1 # any number rais...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" 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,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
#!/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,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
* text=auto
* text=auto
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" A pure Python implementation of the quick sort algorithm For doctests run following command: python3 -m doctest -v quick_sort.py For manual testing run: python3 quick_sort.py """ from typing import List def quick_sort(collection: list) -> list: """A pure Python implementation of quick sort algorithm :p...
""" A pure Python implementation of the quick sort algorithm For doctests run following command: python3 -m doctest -v quick_sort.py For manual testing run: python3 quick_sort.py """ from typing import List def quick_sort(collection: list) -> list: """A pure Python implementation of quick sort algorithm :p...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
DIRCeu Seu S\R(!+NG #ʸ .coveragerceZ3deZ3d\G jERrgk k#.gitattributeseu Seu S\IG& LL1o쟓o .github/CODEOWNERSevev\K>|(o\ITH3)v .github/pull_request_template.mder`8er`8\P 6V&k&g:d5 +.g...
DIRCeu Seu S\R(!+NG #ʸ .coveragerceZ3deZ3d\G jERrgk k#.gitattributeseu Seu S\IG& LL1o쟓o .github/CODEOWNERSevev\K>|(o\ITH3)v .github/pull_request_template.mder`8er`8\P 6V&k&g:d5 +.g...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
def max_subarray_sum(nums: list) -> int: """ >>> max_subarray_sum([6 , 9, -1, 3, -7, -5, 10]) 17 """ if not nums: return 0 n = len(nums) res, s, s_pre = nums[0], nums[0], nums[0] for i in range(1, n): s = max(nums[i], s_pre + nums[i]) s_pre = s res = max(...
def max_subarray_sum(nums: list) -> int: """ >>> max_subarray_sum([6 , 9, -1, 3, -7, -5, 10]) 17 """ if not nums: return 0 n = len(nums) res, s, s_pre = nums[0], nums[0], nums[0] for i in range(1, n): s = max(nums[i], s_pre + nums[i]) s_pre = s res = max(...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Combinatoric selections Problem 53 There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10. In general, nCr = n!/(r!(n−r)!),where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1. It is not until n = 23, t...
""" Combinatoric selections Problem 53 There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3 = 10. In general, nCr = n!/(r!(n−r)!),where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1. It is not until n = 23, t...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" The number of partitions of a number n into at least k parts equals the number of partitions into exactly k parts plus the number of partitions into at least k-1 parts. Subtracting 1 from each part of a partition of n into k parts gives a partition of n-k into k parts. These two facts together are used for this alg...
""" The number of partitions of a number n into at least k parts equals the number of partitions into exactly k parts plus the number of partitions into at least k-1 parts. Subtracting 1 from each part of a partition of n into k parts gives a partition of n-k into k parts. These two facts together are used for this alg...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Changing contrast with PIL This algorithm is used in https://noivce.pythonanywhere.com/ Python web app. python/black: True flake8 : True """ from PIL import Image def change_contrast(img: Image, level: int) -> Image: """ Function to change contrast """ factor = (259 * (level + 255)) / (255 * (2...
""" Changing contrast with PIL This algorithm is used in https://noivce.pythonanywhere.com/ Python web app. python/black: True flake8 : True """ from PIL import Image def change_contrast(img: Image, level: int) -> Image: """ Function to change contrast """ factor = (259 * (level + 255)) / (255 * (2...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" This is a pure Python implementation of the Geometric Series algorithm https://en.wikipedia.org/wiki/Geometric_series Run the doctests with the following command: python3 -m doctest -v geometric_series.py or python -m doctest -v geometric_series.py For manual testing run: python3 geometric_series.py """ def geom...
""" This is a pure Python implementation of the Geometric Series algorithm https://en.wikipedia.org/wiki/Geometric_series Run the doctests with the following command: python3 -m doctest -v geometric_series.py or python -m doctest -v geometric_series.py For manual testing run: python3 geometric_series.py """ def geom...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
from __future__ import annotations from collections import Counter from random import random class MarkovChainGraphUndirectedUnweighted: """ Undirected Unweighted Graph for running Markov Chain Algorithm """ def __init__(self): self.connections = {} def add_node(self, node: str) -> None...
from __future__ import annotations from collections import Counter from random import random class MarkovChainGraphUndirectedUnweighted: """ Undirected Unweighted Graph for running Markov Chain Algorithm """ def __init__(self): self.connections = {} def add_node(self, node: str) -> None...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
import tensorflow as tf from random import shuffle from numpy import array def TFKMeansCluster(vectors, noofclusters): """ K-Means Clustering using TensorFlow. 'vectors' should be a n*k 2-D NumPy array, where n is the number of vectors of dimensionality k. 'noofclusters' should be an integer. ...
import tensorflow as tf from random import shuffle from numpy import array def TFKMeansCluster(vectors, noofclusters): """ K-Means Clustering using TensorFlow. 'vectors' should be a n*k 2-D NumPy array, where n is the number of vectors of dimensionality k. 'noofclusters' should be an integer. ...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" Project Euler Problem 56: https://projecteuler.net/problem=56 A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the fo...
""" Project Euler Problem 56: https://projecteuler.net/problem=56 A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1. Considering natural numbers of the fo...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
alphabet = { "A": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "B": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "C": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "D": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "E": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "F": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "G": ("ABCDEFGHIJKLM", "XYZNOPQRS...
alphabet = { "A": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "B": ("ABCDEFGHIJKLM", "NOPQRSTUVWXYZ"), "C": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "D": ("ABCDEFGHIJKLM", "ZNOPQRSTUVWXY"), "E": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "F": ("ABCDEFGHIJKLM", "YZNOPQRSTUVWX"), "G": ("ABCDEFGHIJKLM", "XYZNOPQRS...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
""" In this problem, we want to determine all possible subsequences of the given sequence. We use backtracking to solve this problem. Time complexity: O(2^n), where n denotes the length of the given sequence. """ from typing import Any, List def generate_all_subsequences(sequence: List[Any]) -> None: create_stat...
""" In this problem, we want to determine all possible subsequences of the given sequence. We use backtracking to solve this problem. Time complexity: O(2^n), where n denotes the length of the given sequence. """ from typing import Any, List def generate_all_subsequences(sequence: List[Any]) -> None: create_stat...
-1
TheAlgorithms/Python
4,247
[mypy] Add/fix type annotations for electronics algorithms
``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAl...
shan7030
2021-03-01T16:50:26Z
2021-03-18T07:39:53Z
ced83bed2cda5a1a4353f3ced2871a884d380879
4f6a929503ac4ee427e85896d1354b50f465ddb4
[mypy] Add/fix type annotations for electronics algorithms. ``` $ mypy electronics/ Success: no issues found in 2 source files ``` Related Issue: #4052 ### **Describe your change:** * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** ...
def quick_sort_3partition(sorting: list, left: int, right: int) -> None: if right <= left: return a = i = left b = right pivot = sorting[left] while i <= b: if sorting[i] < pivot: sorting[a], sorting[i] = sorting[i], sorting[a] a += 1 i += 1 ...
def quick_sort_3partition(sorting: list, left: int, right: int) -> None: if right <= left: return a = i = left b = right pivot = sorting[left] while i <= b: if sorting[i] < pivot: sorting[a], sorting[i] = sorting[i], sorting[a] a += 1 i += 1 ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
#!/usr/bin/env python3 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each buc...
#!/usr/bin/env python3 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each buc...
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" https://en.wikipedia.org/wiki/Cocktail_shaker_sort """ def cocktail_shaker_sort(unsorted: list) -> list: """ Pure implementation of the cocktail shaker sort algorithm in Python. >>> cocktail_shaker_sort([4, 5, 2, 1, 2]) [1, 2, 2, 4, 5] >>> cocktail_shaker_sort([-4, 5, 0, 1, 2, 11]) [-4, 0...
""" https://en.wikipedia.org/wiki/Cocktail_shaker_sort """ def cocktail_shaker_sort(unsorted: list) -> list: """ Pure implementation of the cocktail shaker sort algorithm in Python. >>> cocktail_shaker_sort([4, 5, 2, 1, 2]) [1, 2, 2, 4, 5] >>> cocktail_shaker_sort([-4, 5, 0, 1, 2, 11]) [-4, 0...
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from bisect import bisect_left from functools import total_ordering from heapq import merge """ A pure Python implementation of the patience sort algorithm For more information: https://en.wikipedia.org/wiki/Patience_sorting This algorithm is based on the card game patience For doctests run following command: pytho...
from bisect import bisect_left from functools import total_ordering from heapq import merge from typing import List """ A pure Python implementation of the patience sort algorithm For more information: https://en.wikipedia.org/wiki/Patience_sorting This algorithm is based on the card game patience For doctests run ...
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" 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,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" A recursive implementation of the insertion sort algorithm """ from __future__ import annotations def rec_insertion_sort(collection: list, n: int): """ Given a collection of numbers and its length, sorts the collections in ascending order :param collection: A mutable collection of comparable ele...
""" A recursive implementation of the insertion sort algorithm """ from __future__ import annotations from typing import List def rec_insertion_sort(collection: list, n: int): """ Given a collection of numbers and its length, sorts the collections in ascending order :param collection: A mutable col...
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" This is a pure Python implementation of the P-Series algorithm https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#P-series For doctests run following command: python -m doctest -v p_series.py or python3 -m doctest -v p_series.py For manual testing run: python3 p_series.py """ def p_series(nth_term: int...
""" This is a pure Python implementation of the P-Series algorithm https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)#P-series For doctests run following command: python -m doctest -v p_series.py or python3 -m doctest -v p_series.py For manual testing run: python3 p_series.py """ def p_series(nth_term: int...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from math import asin, atan, cos, radians, sin, sqrt, tan def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float: """ Calculate great circle distance between two points in a sphere, given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula We know tha...
from math import asin, atan, cos, radians, sin, sqrt, tan def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float: """ Calculate great circle distance between two points in a sphere, given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula We know tha...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) ...
from typing import Optional class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Optional[Node] = None self.right: Optional[Node] = None def display(tree: Optional[Node]) ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ def solution(n: int = 600851475143...
""" Project Euler Problem 3: https://projecteuler.net/problem=3 Largest prime factor The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? References: - https://en.wikipedia.org/wiki/Prime_number#Unique_factorization """ def solution(n: int = 600851475143...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" 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,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from typing import List def kmp(pattern: str, text: str) -> bool: """ The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) 1) Preprocess pattern to identify any suffixes that are identical to prefixes This tells us where to continue from if w...
from typing import List def kmp(pattern: str, text: str) -> bool: """ The Knuth-Morris-Pratt Algorithm for finding a pattern within a piece of text with complexity O(n + m) 1) Preprocess pattern to identify any suffixes that are identical to prefixes This tells us where to continue from if w...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" 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,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
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,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. ""...
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. ""...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from typing import List def median_of_two_arrays(nums1: List[float], nums2: List[float]) -> float: """ >>> median_of_two_arrays([1, 2], [3]) 2 >>> median_of_two_arrays([0, -1.1], [2.5, 1]) 0.5 >>> median_of_two_arrays([], [2.5, 1]) 1.75 >>> median_of_two_arrays([], [0]) 0 >>> m...
from typing import List def median_of_two_arrays(nums1: List[float], nums2: List[float]) -> float: """ >>> median_of_two_arrays([1, 2], [3]) 2 >>> median_of_two_arrays([0, -1.1], [2.5, 1]) 0.5 >>> median_of_two_arrays([], [2.5, 1]) 1.75 >>> median_of_two_arrays([], [0]) 0 >>> m...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_...
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
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 coeffiecients of a polynomial as an iterable in order of ascending degree x -- the point at which to eva...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
import base64 def main(): inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == ...
import base64 def main(): inp = input("->") encoded = inp.encode("utf-8") # encoded the input (we need a bytes like object) a85encoded = base64.a85encode(encoded) # a85encoded the encoded string print(a85encoded) print(base64.a85decode(a85encoded).decode("utf-8")) # decoded it if __name__ == ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" https://en.wikipedia.org/wiki/Euclidean_algorithm """ def euclidean_gcd(a: int, b: int) -> int: """ Examples: >>> euclidean_gcd(3, 5) 1 >>> euclidean_gcd(6, 3) 3 """ while b: a, b = b, a % b return a def euclidean_gcd_recursive(a: int, b: int) -> int: """ Rec...
""" https://en.wikipedia.org/wiki/Euclidean_algorithm """ def euclidean_gcd(a: int, b: int) -> int: """ Examples: >>> euclidean_gcd(3, 5) 1 >>> euclidean_gcd(6, 3) 3 """ while b: a, b = b, a % b return a def euclidean_gcd_recursive(a: int, b: int) -> int: """ Rec...
-1