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,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Given a array of length n, max_subarray_sum() finds
the maximum of sum of contiguous sub-array using divide and conquer method.
Time complexity : O(n log n)
Ref : INTRODUCTION TO ALGORITHMS THIRD EDITION
(section : 4, sub-section : 4.1, page : 70)
"""
def max_sum_from_start(array):
"""This function finds t... | """
Given a array of length n, max_subarray_sum() finds
the maximum of sum of contiguous sub-array using divide and conquer method.
Time complexity : O(n log n)
Ref : INTRODUCTION TO ALGORITHMS THIRD EDITION
(section : 4, sub-section : 4.1, page : 70)
"""
def max_sum_from_start(array):
"""This function finds t... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | class StackOverflowError(BaseException):
pass
class Stack:
"""A stack is an abstract data type that serves as a collection of
elements with two principal operations: push() and pop(). push() adds an
element to the top of the stack, and pop() removes an element from the top
of a stack. The order in... | class StackOverflowError(BaseException):
pass
class Stack:
"""A stack is an abstract data type that serves as a collection of
elements with two principal operations: push() and pop(). push() adds an
element to the top of the stack, and pop() removes an element from the top
of a stack. The order in... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | import cv2
import numpy as np
from digital_image_processing.filters.convolve import img_convolve
from digital_image_processing.filters.sobel_filter import sobel_filter
PI = 180
def gen_gaussian_kernel(k_size, sigma):
center = k_size // 2
x, y = np.mgrid[0 - center : k_size - center, 0 - center : k_size - ce... | import cv2
import numpy as np
from digital_image_processing.filters.convolve import img_convolve
from digital_image_processing.filters.sobel_filter import sobel_filter
PI = 180
def gen_gaussian_kernel(k_size, sigma):
center = k_size // 2
x, y = np.mgrid[0 - center : k_size - center, 0 - center : k_size - ce... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from typing import Iterable, Union
import numpy as np
Vector = Union[Iterable[float], Iterable[int], np.ndarray]
VectorOut = Union[np.float64, int, float]
def euclidean_distance(vector_1: Vector, vector_2: Vector) -> VectorOut:
"""
Calculate the distance between the two endpoints of two vectors.
A vecto... | from typing import Iterable, Union
import numpy as np
Vector = Union[Iterable[float], Iterable[int], np.ndarray]
VectorOut = Union[np.float64, int, float]
def euclidean_distance(vector_1: Vector, vector_2: Vector) -> VectorOut:
"""
Calculate the distance between the two endpoints of two vectors.
A vecto... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def factorial(num: int) -> int:
"""F... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def factorial(num: int) -> int:
"""F... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | -1 | ||
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from PIL import Image
def change_brightness(img: Image, level: float) -> Image:
"""
Change the brightness of a PIL Image to a given level.
"""
def brightness(c: int) -> float:
"""
Fundamental Transformation/Operation that'll be performed on
every bit.
"""
retur... | from PIL import Image
def change_brightness(img: Image, level: float) -> Image:
"""
Change the brightness of a PIL Image to a given level.
"""
def brightness(c: int) -> float:
"""
Fundamental Transformation/Operation that'll be performed on
every bit.
"""
retur... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """Non recursive implementation of a DFS algorithm."""
from __future__ import annotations
def depth_first_search(graph: dict, start: str) -> set[int]:
"""Depth First Search on Graph
:param graph: directed graph in dictionary format
:param vertex: starting vertex as a string
:returns: the trace of the... | """Non recursive implementation of a DFS algorithm."""
from __future__ import annotations
def depth_first_search(graph: dict, start: str) -> set[int]:
"""Depth First Search on Graph
:param graph: directed graph in dictionary format
:param vertex: starting vertex as a string
:returns: the trace of the... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
This is pure Python implementation of Tabu search algorithm for a Travelling Salesman
Problem, that the distances between the cities are symmetric (the distance between city
'a' and city 'b' is the same between city 'b' and city 'a').
The TSP can be represented into a graph. The cities are represented by nodes and ... | """
This is pure Python implementation of Tabu search algorithm for a Travelling Salesman
Problem, that the distances between the cities are symmetric (the distance between city
'a' and city 'b' is the same between city 'b' and city 'a').
The TSP can be represented into a graph. The cities are represented by nodes and ... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from .stack import Stack
def balanced_parentheses(parentheses: str) -> bool:
"""Use a stack to check if a string of parentheses is balanced.
>>> balanced_parentheses("([]{})")
True
>>> balanced_parentheses("[()]{}{[()()]()}")
True
>>> balanced_parentheses("[(])")
False
>>> balanced_par... | from .stack import Stack
def balanced_parentheses(parentheses: str) -> bool:
"""Use a stack to check if a string of parentheses is balanced.
>>> balanced_parentheses("([]{})")
True
>>> balanced_parentheses("[()]{}{[()()]()}")
True
>>> balanced_parentheses("[(])")
False
>>> balanced_par... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Heap's 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 python implem... | """
Heap's 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 python implem... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """ 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,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | # Recursive Prorgam to create a Linked List from a sequence and
# print a string representation of it.
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
def __repr__(self):
"""Returns a visual representation of the node and all its following nodes."""
... | # Recursive Prorgam to create a Linked List from a sequence and
# print a string representation of it.
class Node:
def __init__(self, data=None):
self.data = data
self.next = None
def __repr__(self):
"""Returns a visual representation of the node and all its following nodes."""
... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Problem 46: https://projecteuler.net/problem=46
It was proposed by Christian Goldbach that every odd composite number can be
written as the sum of a prime and twice a square.
9 = 7 + 2 × 12
15 = 7 + 2 × 22
21 = 3 + 2 × 32
25 = 7 + 2 × 32
27 = 19 + 2 × 22
33 = 31 + 2 × 12
It turns out that the conjecture was fals... | """
Problem 46: https://projecteuler.net/problem=46
It was proposed by Christian Goldbach that every odd composite number can be
written as the sum of a prime and twice a square.
9 = 7 + 2 × 12
15 = 7 + 2 × 22
21 = 3 + 2 × 32
25 = 7 + 2 × 32
27 = 19 + 2 × 22
33 = 31 + 2 × 12
It turns out that the conjecture was fals... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Convert International System of Units (SI) and Binary prefixes
"""
from enum import Enum
from typing import Union
class SI_Unit(Enum):
yotta = 24
zetta = 21
exa = 18
peta = 15
tera = 12
giga = 9
mega = 6
kilo = 3
hecto = 2
deca = 1
deci = -1
centi = -2
milli = -... | """
Convert International System of Units (SI) and Binary prefixes
"""
from enum import Enum
from typing import Union
class SI_Unit(Enum):
yotta = 24
zetta = 21
exa = 18
peta = 15
tera = 12
giga = 9
mega = 6
kilo = 3
hecto = 2
deca = 1
deci = -1
centi = -2
milli = -... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Find Volumes of Various Shapes.
Wikipedia reference: https://en.wikipedia.org/wiki/Volume
"""
from math import pi, pow
from typing import Union
def vol_cube(side_length: Union[int, float]) -> float:
"""
Calculate the Volume of a Cube.
>>> vol_cube(1)
1.0
>>> vol_cube(3)
27.0
"""
... | """
Find Volumes of Various Shapes.
Wikipedia reference: https://en.wikipedia.org/wiki/Volume
"""
from math import pi, pow
from typing import Union
def vol_cube(side_length: Union[int, float]) -> float:
"""
Calculate the Volume of a Cube.
>>> vol_cube(1)
1.0
>>> vol_cube(3)
27.0
"""
... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | END = "#"
class Trie:
def __init__(self):
self._trie = {}
def insert_word(self, text):
trie = self._trie
for char in text:
if char not in trie:
trie[char] = {}
trie = trie[char]
trie[END] = True
def find_word(self, prefix):
... | END = "#"
class Trie:
def __init__(self):
self._trie = {}
def insert_word(self, text):
trie = self._trie
for char in text:
if char not in trie:
trie[char] = {}
trie = trie[char]
trie[END] = True
def find_word(self, prefix):
... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
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
"""
from math import sqrt
def is_prime(... | """
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
"""
from math import sqrt
def is_prime(... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
GEOMETRIC MEAN : https://en.wikipedia.org/wiki/Geometric_mean
"""
def is_geometric_series(series: list) -> bool:
"""
checking whether the input series is geometric series or not
>>> is_geometric_series([2, 4, 8])
True
>>> is_geometric_series([3, 6, 12, 24])
True
>>> is_geometric_seri... | """
GEOMETRIC MEAN : https://en.wikipedia.org/wiki/Geometric_mean
"""
def is_geometric_series(series: list) -> bool:
"""
checking whether the input series is geometric series or not
>>> is_geometric_series([2, 4, 8])
True
>>> is_geometric_series([3, 6, 12, 24])
True
>>> is_geometric_seri... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from typing import List, Tuple
"""
Algorithm for calculating the most cost-efficient sequence for converting one string
into another.
The only allowed operations are
--- Cost to copy a character is copy_cost
--- Cost to replace a character is replace_cost
--- Cost to delete a character is delete_cost
--- Cost to inser... | from typing import List, Tuple
"""
Algorithm for calculating the most cost-efficient sequence for converting one string
into another.
The only allowed operations are
--- Cost to copy a character is copy_cost
--- Cost to replace a character is replace_cost
--- Cost to delete a character is delete_cost
--- Cost to inser... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Get the citation from google scholar
using title and year of publication, and volume and pages of journal.
"""
import requests
from bs4 import BeautifulSoup
def get_citation(base_url: str, params: dict) -> str:
"""
Return the citation number.
"""
soup = BeautifulSoup(requests.get(base_url, params... | """
Get the citation from google scholar
using title and year of publication, and volume and pages of journal.
"""
import requests
from bs4 import BeautifulSoup
def get_citation(base_url: str, params: dict) -> str:
"""
Return the citation number.
"""
soup = BeautifulSoup(requests.get(base_url, params... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Project Euler Problem 2: https://projecteuler.net/problem=2
Even Fibonacci Numbers
Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequenc... | """
Project Euler Problem 2: https://projecteuler.net/problem=2
Even Fibonacci Numbers
Each new term in the Fibonacci sequence is generated by adding the previous
two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
By considering the terms in the Fibonacci sequenc... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Problem 43: https://projecteuler.net/problem=43
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of
each of the digits 0 to 9 in some order, but it also has a rather interesting
sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we no... | """
Problem 43: https://projecteuler.net/problem=43
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of
each of the digits 0 to 9 in some order, but it also has a rather interesting
sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we no... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | #
| #
| -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from typing import List
def solve_maze(maze: List[List[int]]) -> bool:
"""
This method solves the "rat in maze" problem.
In this problem we have some n by n matrix, a start point and an end point.
We want to go from the start to the end. In this matrix zeroes represent walls
and ones paths we can ... | from typing import List
def solve_maze(maze: List[List[int]]) -> bool:
"""
This method solves the "rat in maze" problem.
In this problem we have some n by n matrix, a start point and an end point.
We want to go from the start to the end. In this matrix zeroes represent walls
and ones paths we can ... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | class Heap:
"""
A generic Heap class, can be used as min or max by passing the key function
accordingly.
"""
def __init__(self, key=None):
# Stores actual heap items.
self.arr = list()
# Stores indexes of each item for supporting updates and deletion.
self.pos_map = ... | class Heap:
"""
A generic Heap class, can be used as min or max by passing the key function
accordingly.
"""
def __init__(self, key=None):
# Stores actual heap items.
self.arr = list()
# Stores indexes of each item for supporting updates and deletion.
self.pos_map = ... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from __future__ import annotations
import csv
import requests
from bs4 import BeautifulSoup
def get_imdb_top_250_movies(url: str = "") -> dict[str, float]:
url = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250"
soup = BeautifulSoup(requests.get(url).text, "html.parser")
titles = soup.find_all("td... | from __future__ import annotations
import csv
import requests
from bs4 import BeautifulSoup
def get_imdb_top_250_movies(url: str = "") -> dict[str, float]:
url = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250"
soup = BeautifulSoup(requests.get(url).text, "html.parser")
titles = soup.find_all("td... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | class things:
def __init__(self, name, value, weight):
self.name = name
self.value = value
self.weight = weight
def __repr__(self):
return f"{self.__class__.__name__}({self.name}, {self.value}, {self.weight})"
def get_value(self):
return self.value
def get_name... | class things:
def __init__(self, name, value, weight):
self.name = name
self.value = value
self.weight = weight
def __repr__(self):
return f"{self.__class__.__name__}({self.name}, {self.value}, {self.weight})"
def get_value(self):
return self.value
def get_name... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | from __future__ import annotations
import random
class Dice:
NUM_SIDES = 6
def __init__(self):
""" Initialize a six sided dice """
self.sides = list(range(1, Dice.NUM_SIDES + 1))
def roll(self):
return random.choice(self.sides)
def _str_(self):
return "Fair Dice"
... | from __future__ import annotations
import random
class Dice:
NUM_SIDES = 6
def __init__(self):
""" Initialize a six sided dice """
self.sides = list(range(1, Dice.NUM_SIDES + 1))
def roll(self):
return random.choice(self.sides)
def _str_(self):
return "Fair Dice"
... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | # flake8: noqa
"""
Binomial Heap
Reference: Advanced Data Structures, Peter Brass
"""
class Node:
"""
Node in a doubly-linked binomial tree, containing:
- value
- size of left subtree
- link to left, right and parent nodes
"""
def __init__(self, val):
self.val = val
... | # flake8: noqa
"""
Binomial Heap
Reference: Advanced Data Structures, Peter Brass
"""
class Node:
"""
Node in a doubly-linked binomial tree, containing:
- value
- size of left subtree
- link to left, right and parent nodes
"""
def __init__(self, val):
self.val = val
... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
This is to show simple COVID19 info fetching from worldometers site using lxml
* The main motivation to use lxml in place of bs4 is that it is faster and therefore
more convenient to use in Python web projects (e.g. Django or Flask-based)
"""
from collections import namedtuple
import requests
from lxml import htm... | """
This is to show simple COVID19 info fetching from worldometers site using lxml
* The main motivation to use lxml in place of bs4 is that it is faster and therefore
more convenient to use in Python web projects (e.g. Django or Flask-based)
"""
from collections import namedtuple
import requests
from lxml import htm... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | import math
"""
In cryptography, the TRANSPOSITION cipher is a method of encryption where the
positions of plaintext are shifted a certain number(determined by the key) that
follows a regular system that results in the permuted text, known as the encrypted
text. The type of transposition cipher demonstrated under is t... | import math
"""
In cryptography, the TRANSPOSITION cipher is a method of encryption where the
positions of plaintext are shifted a certain number(determined by the key) that
follows a regular system that results in the permuted text, known as the encrypted
text. The type of transposition cipher demonstrated under is t... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
Project Euler Problem 129: https://projecteuler.net/problem=129
A number consisting entirely of ones is called a repunit. We shall define R(k) to be
a repunit of length k; for example, R(6) = 111111.
Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there
always exists a value, k, for wh... | """
Project Euler Problem 129: https://projecteuler.net/problem=129
A number consisting entirely of ones is called a repunit. We shall define R(k) to be
a repunit of length k; for example, R(6) = 111111.
Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there
always exists a value, k, for wh... | -1 |
TheAlgorithms/Python | 4,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | """
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... | """
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,304 | [mypy] Fix directory arithmetic_analysis | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-04-02T07:15:46Z | 2021-04-02T07:32:13Z | 895bca36541598a04dba525568a20d2282e0ffd9 | 5229c749553d9ec65d455e0183a574e45ac3e73e | [mypy] Fix directory arithmetic_analysis. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRI... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | 1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
This is used to convert the currency using the Amdoren Currency API
https://www.amdoren.com
"""
import os
import requests
URL_BASE = "https://www.amdoren.com/api/currency.php"
TESTING = os.getenv("CI", False)
API_KEY = os.getenv("AMDOREN_API_KEY")
if not API_KEY and not TESTING:
raise KeyError("Please put yo... | """
This is used to convert the currency using the Amdoren Currency API
https://www.amdoren.com
"""
import os
import requests
URL_BASE = "https://www.amdoren.com/api/currency.php"
TESTING = os.getenv("CI", False)
API_KEY = os.getenv("AMDOREN_API_KEY", "")
if not API_KEY and not TESTING:
raise KeyError("Please pu... | 1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """Get the site emails from URL."""
__author__ = "Muhammad Umer Farooq"
__license__ = "MIT"
__version__ = "1.0.0"
__maintainer__ = "Muhammad Umer Farooq"
__email__ = "contact@muhammadumerfarooq.me"
__status__ = "Alpha"
import re
from html.parser import HTMLParser
from urllib import parse
import requests
class Parse... | """Get the site emails from URL."""
__author__ = "Muhammad Umer Farooq"
__license__ = "MIT"
__version__ = "1.0.0"
__maintainer__ = "Muhammad Umer Farooq"
__email__ = "contact@muhammadumerfarooq.me"
__status__ = "Alpha"
import re
from html.parser import HTMLParser
from typing import Optional
from urllib import parse
i... | 1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | # Print all subset combinations of n element in given set of r element.
def combination_util(arr, n, r, index, data, i):
"""
Current combination is ready to be printed, print it
arr[] ---> Input Array
data[] ---> Temporary array to store current combination
start & end ---> Staring and Ending ind... | # Print all subset combinations of n element in given set of r element.
def combination_util(arr, n, r, index, data, i):
"""
Current combination is ready to be printed, print it
arr[] ---> Input Array
data[] ---> Temporary array to store current combination
start & end ---> Staring and Ending ind... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | # Check whether Graph is Bipartite or Not using BFS
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# o... | # Check whether Graph is Bipartite or Not using BFS
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# o... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | 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,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | import cv2
import numpy as np
"""
Harris Corner Detector
https://en.wikipedia.org/wiki/Harris_Corner_Detector
"""
class Harris_Corner:
def __init__(self, k: float, window_size: int):
"""
k : is an empirically determined constant in [0.04,0.06]
window_size : neighbourhoods considered
... | import cv2
import numpy as np
"""
Harris Corner Detector
https://en.wikipedia.org/wiki/Harris_Corner_Detector
"""
class Harris_Corner:
def __init__(self, k: float, window_size: int):
"""
k : is an empirically determined constant in [0.04,0.06]
window_size : neighbourhoods considered
... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """Absolute Value."""
def abs_val(num):
"""
Find the absolute value of a number.
>>> abs_val(-5.1)
5.1
>>> abs_val(-5) == abs_val(5)
True
>>> abs_val(0)
0
"""
return -num if num < 0 else num
def test_abs_val():
"""
>>> test_abs_val()
"""
assert 0 == abs_val(0... | """Absolute Value."""
def abs_val(num):
"""
Find the absolute value of a number.
>>> abs_val(-5.1)
5.1
>>> abs_val(-5) == abs_val(5)
True
>>> abs_val(0)
0
"""
return -num if num < 0 else num
def test_abs_val():
"""
>>> test_abs_val()
"""
assert 0 == abs_val(0... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
Given a sorted array of integers, return indices of the two numbers such
that they add up to a specific target using the two pointers technique.
You may assume that each input would have exactly one solution, and you
may not use the same element twice.
This is an alternative solution of the two-sum problem, which... | """
Given a sorted array of integers, return indices of the two numbers such
that they add up to a specific target using the two pointers technique.
You may assume that each input would have exactly one solution, and you
may not use the same element twice.
This is an alternative solution of the two-sum problem, which... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
The number 3797 has an interesting property. Being prime itself, it is possible
to continuously remove digits from left to right, and remain prime at each stage:
3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the sum of the only eleven primes that are both truncatable fr... | """
The number 3797 has an interesting property. Being prime itself, it is possible
to continuously remove digits from left to right, and remain prime at each stage:
3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
Find the sum of the only eleven primes that are both truncatable fr... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | # Check whether Graph is Bipartite or Not using DFS
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# o... | # Check whether Graph is Bipartite or Not using DFS
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# o... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | r"""
Problem:
The n queens problem is of placing N queens on a N * N chess board such that no queen
can attack any other queens placed on that chess board. This means that one queen
cannot have any other queen on its horizontal, vertical and diagonal lines.
Solution:
To solve this problem we will use simple math. F... | r"""
Problem:
The n queens problem is of placing N queens on a N * N chess board such that no queen
can attack any other queens placed on that chess board. This means that one queen
cannot have any other queen on its horizontal, vertical and diagonal lines.
Solution:
To solve this problem we will use simple math. F... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
The Reverse Polish Nation also known as Polish postfix notation
or simply postfix notation.
https://en.wikipedia.org/wiki/Reverse_Polish_notation
Classic examples of simple stack implementations
Valid operators are +, -, *, /.
Each operand may be an integer or another expression.
"""
def evaluate_postfix(postfix_... | """
The Reverse Polish Nation also known as Polish postfix notation
or simply postfix notation.
https://en.wikipedia.org/wiki/Reverse_Polish_notation
Classic examples of simple stack implementations
Valid operators are +, -, *, /.
Each operand may be an integer or another expression.
"""
def evaluate_postfix(postfix_... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
Graph Coloring also called "m coloring problem"
consists of coloring given graph with at most m colors
such that no adjacent vertices are assigned same color
Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring
"""
from typing import List
def valid_coloring(
neighbours: List[int], colored_... | """
Graph Coloring also called "m coloring problem"
consists of coloring given graph with at most m colors
such that no adjacent vertices are assigned same color
Wikipedia: https://en.wikipedia.org/wiki/Graph_coloring
"""
from typing import List
def valid_coloring(
neighbours: List[int], colored_... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | def max_difference(a: list[int]) -> tuple[int, int]:
"""
We are given an array A[1..n] of integers, n >= 1. We want to
find a pair of indices (i, j) such that
1 <= i <= j <= n and A[j] - A[i] is as large as possible.
Explanation:
https://www.geeksforgeeks.org/maximum-difference-between-two-elem... | def max_difference(a: list[int]) -> tuple[int, int]:
"""
We are given an array A[1..n] of integers, n >= 1. We want to
find a pair of indices (i, j) such that
1 <= i <= j <= n and A[j] - A[i] is as large as possible.
Explanation:
https://www.geeksforgeeks.org/maximum-difference-between-two-elem... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
This is a Python implementation of the levenshtein distance.
Levenshtein distance is a string metric for measuring the
difference between two sequences.
For doctests run following command:
python -m doctest -v levenshtein-distance.py
or
python3 -m doctest -v levenshtein-distance.py
For manual testing run:
python ... | """
This is a Python implementation of the levenshtein distance.
Levenshtein distance is a string metric for measuring the
difference between two sequences.
For doctests run following command:
python -m doctest -v levenshtein-distance.py
or
python3 -m doctest -v levenshtein-distance.py
For manual testing run:
python ... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
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,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | import random
import string
class ShuffledShiftCipher:
"""
This algorithm uses the Caesar Cipher algorithm but removes the option to
use brute force to decrypt the message.
The passcode is a a random password from the selection buffer of
1. uppercase letters of the English alphabet
2. lowerca... | import random
import string
class ShuffledShiftCipher:
"""
This algorithm uses the Caesar Cipher algorithm but removes the option to
use brute force to decrypt the message.
The passcode is a a random password from the selection buffer of
1. uppercase letters of the English alphabet
2. lowerca... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | from typing import Any
class ContainsLoopError(Exception):
pass
class Node:
def __init__(self, data: Any) -> None:
self.data = data
self.next_node = None
def __iter__(self):
node = self
visited = []
while node:
if node in visited:
rais... | from typing import Any
class ContainsLoopError(Exception):
pass
class Node:
def __init__(self, data: Any) -> None:
self.data = data
self.next_node = None
def __iter__(self):
node = self
visited = []
while node:
if node in visited:
rais... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | import os
from itertools import chain
from random import randrange, shuffle
import pytest
from .sol1 import PokerHand
SORTED_HANDS = (
"4S 3H 2C 7S 5H",
"9D 8H 2C 6S 7H",
"2D 6D 9D TH 7D",
"TC 8C 2S JH 6C",
"JH 8S TH AH QH",
"TS KS 5S 9S AC",
"KD 6S 9D TH AD",
"KS 8D 4D 9S 4S", # pai... | import os
from itertools import chain
from random import randrange, shuffle
import pytest
from .sol1 import PokerHand
SORTED_HANDS = (
"4S 3H 2C 7S 5H",
"9D 8H 2C 6S 7H",
"2D 6D 9D TH 7D",
"TC 8C 2S JH 6C",
"JH 8S TH AH QH",
"TS KS 5S 9S AC",
"KD 6S 9D TH AD",
"KS 8D 4D 9S 4S", # pai... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | # NguyenU
def find_max(nums):
"""
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
... find_max(nums) == max(nums)
True
True
True
True
"""
max_num = nums[0]
for x in nums:
if x > max_num:
max_num = x
return max_num
def main()... | # NguyenU
def find_max(nums):
"""
>>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]):
... find_max(nums) == max(nums)
True
True
True
True
"""
max_num = nums[0]
for x in nums:
if x > max_num:
max_num = x
return max_num
def main()... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | # Numbers of alphabet which we call base
alphabet_size = 256
# Modulus to hash a string
modulus = 1000003
def rabin_karp(pattern: str, text: str) -> bool:
"""
The Rabin-Karp Algorithm for finding a pattern within a piece of text
with complexity O(nm), most efficient when it is used with multiple patterns
... | # Numbers of alphabet which we call base
alphabet_size = 256
# Modulus to hash a string
modulus = 1000003
def rabin_karp(pattern: str, text: str) -> bool:
"""
The Rabin-Karp Algorithm for finding a pattern within a piece of text
with complexity O(nm), most efficient when it is used with multiple patterns
... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
wiki: https://en.wikipedia.org/wiki/Anagram
"""
def check_anagrams(first_str: str, second_str: str) -> bool:
"""
Two strings are anagrams if they are made of the same letters
arranged differently (ignoring the case).
>>> check_anagrams('Silent', 'Listen')
True
>>> check_anagrams('This is a... | """
wiki: https://en.wikipedia.org/wiki/Anagram
"""
def check_anagrams(first_str: str, second_str: str) -> bool:
"""
Two strings are anagrams if they are made of the same letters
arranged differently (ignoring the case).
>>> check_anagrams('Silent', 'Listen')
True
>>> check_anagrams('This is a... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | #
| #
| -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | -1 | ||
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
Test cases:
Do you want to enter your denominations ? (Y/N) :N
Enter the change you want to make in Indian Currency: 987
Following is minimal change for 987 :
500 100 100 100 100 50 20 10 5 2
Do you want to enter your denominations ? (Y/N) :Y
Enter number of denomination:10
1
5
10
20
50
100
200
500
1000
2000
Ente... | """
Test cases:
Do you want to enter your denominations ? (Y/N) :N
Enter the change you want to make in Indian Currency: 987
Following is minimal change for 987 :
500 100 100 100 100 50 20 10 5 2
Do you want to enter your denominations ? (Y/N) :Y
Enter number of denomination:10
1
5
10
20
50
100
200
500
1000
2000
Ente... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | class Heap:
"""
A generic Heap class, can be used as min or max by passing the key function
accordingly.
"""
def __init__(self, key=None):
# Stores actual heap items.
self.arr = list()
# Stores indexes of each item for supporting updates and deletion.
self.pos_map = ... | class Heap:
"""
A generic Heap class, can be used as min or max by passing the key function
accordingly.
"""
def __init__(self, key=None):
# Stores actual heap items.
self.arr = list()
# Stores indexes of each item for supporting updates and deletion.
self.pos_map = ... | -1 |
TheAlgorithms/Python | 4,297 | [mypy] Fix web_programming directory | A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is ... | cclauss | 2021-03-28T01:58:51Z | 2021-03-31T03:18:07Z | c22c7d503be5f48ae257c648f7b83b8a80a02738 | 895bca36541598a04dba525568a20d2282e0ffd9 | [mypy] Fix web_programming directory. A subtask of #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/TheAlgorithms/Python/blob/master/CONTRIBU... | """
Problem 46: https://projecteuler.net/problem=46
It was proposed by Christian Goldbach that every odd composite number can be
written as the sum of a prime and twice a square.
9 = 7 + 2 × 12
15 = 7 + 2 × 22
21 = 3 + 2 × 32
25 = 7 + 2 × 32
27 = 19 + 2 × 22
33 = 31 + 2 × 12
It turns out that the conjecture was fals... | """
Problem 46: https://projecteuler.net/problem=46
It was proposed by Christian Goldbach that every odd composite number can be
written as the sum of a prime and twice a square.
9 = 7 + 2 × 12
15 = 7 + 2 × 22
21 = 3 + 2 × 32
25 = 7 + 2 × 32
27 = 19 + 2 × 22
33 = 31 + 2 × 12
It turns out that the conjecture was fals... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | 1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
this is code for forecasting
but i modified it and used it for safety checker of data
for ex: you have a online shop and for some reason some data are
missing (the amount of data that u expected are not supposed to be)
then we can use it
*ps : 1. ofc we can use normal statistic method but in this case
... | """
this is code for forecasting
but i modified it and used it for safety checker of data
for ex: you have a online shop and for some reason some data are
missing (the amount of data that u expected are not supposed to be)
then we can use it
*ps : 1. ofc we can use normal statistic method but in this case
... | 1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """README, Author - Anurag Kumar(mailto:anuragkumarak95@gmail.com)
Requirements:
- sklearn
- numpy
- matplotlib
Python:
- 3.5
Inputs:
- X , a 2D numpy array of features.
- k , number of clusters to create.
- initial_centroids , initial centroid values generated by utility function(mentioned
in usage).... | """README, Author - Anurag Kumar(mailto:anuragkumarak95@gmail.com)
Requirements:
- sklearn
- numpy
- matplotlib
Python:
- 3.5
Inputs:
- X , a 2D numpy array of features.
- k , number of clusters to create.
- initial_centroids , initial centroid values generated by utility function(mentioned
in usage).... | 1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | import string
from math import log10
"""
tf-idf Wikipedia: https://en.wikipedia.org/wiki/Tf%E2%80%93idf
tf-idf and other word frequency algorithms are often used
as a weighting factor in information retrieval and text
mining. 83% of text-based recommender systems use
tf-idf for term weighting. In L... | import string
from math import log10
"""
tf-idf Wikipedia: https://en.wikipedia.org/wiki/Tf%E2%80%93idf
tf-idf and other word frequency algorithms are often used
as a weighting factor in information retrieval and text
mining. 83% of text-based recommender systems use
tf-idf for term weighting. In L... | 1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Perceptron
w = w + N * (d(k) - y) * x(k)
Using perceptron network for oil analysis, with Measuring of 3 parameters
that represent chemical characteristics we can classify the oil, in p1 or p2
p1 = -1
p2 = 1
"""
import random
class Perceptron:
def __init__(self, sample, target, learnin... | """
Perceptron
w = w + N * (d(k) - y) * x(k)
Using perceptron network for oil analysis, with Measuring of 3 parameters
that represent chemical characteristics we can classify the oil, in p1 or p2
p1 = -1
p2 = 1
"""
import random
class Perceptron:
def __init__(
self,
sample... | 1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # 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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # https://en.wikipedia.org/wiki/Tree_traversal
class Node:
"""
A Node has data variable and pointers to its left and right nodes.
"""
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def make_tree() -> Node:
root = Node(1)
root.left = Nod... | # https://en.wikipedia.org/wiki/Tree_traversal
class Node:
"""
A Node has data variable and pointers to its left and right nodes.
"""
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def make_tree() -> Node:
root = Node(1)
root.left = Nod... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the ... | """
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the ... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Ordered fractions
Problem 71
https://projecteuler.net/problem=71
Consider the fraction n/d, where n and d are positive
integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8
in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, ... | """
Ordered fractions
Problem 71
https://projecteuler.net/problem=71
Consider the fraction n/d, where n and d are positive
integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8
in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, ... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Convert a string of characters to a sequence of numbers
corresponding to the character's position in the alphabet.
https://www.dcode.fr/letter-number-cipher
http://bestcodes.weebly.com/a1z26.html
"""
def encode(plain: str) -> list[int]:
"""
>>> encode("myname")
[13, 25, 14, 1, 13, 5]
"""
retu... | """
Convert a string of characters to a sequence of numbers
corresponding to the character's position in the alphabet.
https://www.dcode.fr/letter-number-cipher
http://bestcodes.weebly.com/a1z26.html
"""
def encode(plain: str) -> list[int]:
"""
>>> encode("myname")
[13, 25, 14, 1, 13, 5]
"""
retu... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def solution(num: int = 100) -> int:
... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def solution(num: int = 100) -> int:
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
This is a pure Python implementation of the bogosort algorithm,
also known as permutation sort, stupid sort, slowsort, shotgun sort, or monkey sort.
Bogosort generates random permutations until it guesses the correct one.
More info on: https://en.wikipedia.org/wiki/Bogosort
For doctests run following command:
pyt... | """
This is a pure Python implementation of the bogosort algorithm,
also known as permutation sort, stupid sort, slowsort, shotgun sort, or monkey sort.
Bogosort generates random permutations until it guesses the correct one.
More info on: https://en.wikipedia.org/wiki/Bogosort
For doctests run following command:
pyt... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # Created by sarathkaul on 17/11/19
# Modified by Arkadip Bhattacharya(@darkmatter18) on 20/04/2020
from collections import defaultdict
def word_occurence(sentence: str) -> dict:
"""
>>> from collections import Counter
>>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0"
>>> occurence_dict = wor... | # Created by sarathkaul on 17/11/19
# Modified by Arkadip Bhattacharya(@darkmatter18) on 20/04/2020
from collections import defaultdict
def word_occurence(sentence: str) -> dict:
"""
>>> from collections import Counter
>>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0"
>>> occurence_dict = wor... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/env python3
"""
Build a simple bare-minimum quantum circuit that starts with a single
qubit (by default, in state 0), runs the experiment 1000 times, and
finally prints the total count of the states finally observed.
Qiskit Docs: https://qiskit.org/documentation/getting_started.html
"""
import qiskit as q
... | #!/usr/bin/env python3
"""
Build a simple bare-minimum quantum circuit that starts with a single
qubit (by default, in state 0), runs the experiment 1000 times, and
finally prints the total count of the states finally observed.
Qiskit Docs: https://qiskit.org/documentation/getting_started.html
"""
import qiskit as q
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # A Python implementation of the Banker's Algorithm in Operating Systems using
# Processes and Resources
# {
# "Author: "Biney Kingsley (bluedistro@github.io), bineykingsley36@gmail.com",
# "Date": 28-10-2018
# }
"""
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm
developed by Edsger Di... | # A Python implementation of the Banker's Algorithm in Operating Systems using
# Processes and Resources
# {
# "Author: "Biney Kingsley (bluedistro@github.io), bineykingsley36@gmail.com",
# "Date": 28-10-2018
# }
"""
The Banker's algorithm is a resource allocation and deadlock avoidance algorithm
developed by Edsger Di... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Implementation Burke's algorithm (dithering)
"""
import numpy as np
from cv2 import destroyAllWindows, imread, imshow, waitKey
class Burkes:
"""
Burke's algorithm is using for converting grayscale image to black and white version
Source: Source: https://en.wikipedia.org/wiki/Dither
Note:
... | """
Implementation Burke's algorithm (dithering)
"""
import numpy as np
from cv2 import destroyAllWindows, imread, imshow, waitKey
class Burkes:
"""
Burke's algorithm is using for converting grayscale image to black and white version
Source: Source: https://en.wikipedia.org/wiki/Dither
Note:
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
== Perfect Number ==
In number theory, a perfect number is a positive integer that is equal to the sum of
its positive divisors, excluding the number itself.
For example: 6 ==> divisors[1, 2, 3, 6]
Excluding 6, the sum(divisors) is 1 + 2 + 3 = 6
So, 6 is a Perfect Number
Other examples of Perfect Numbers: ... | """
== Perfect Number ==
In number theory, a perfect number is a positive integer that is equal to the sum of
its positive divisors, excluding the number itself.
For example: 6 ==> divisors[1, 2, 3, 6]
Excluding 6, the sum(divisors) is 1 + 2 + 3 = 6
So, 6 is a Perfect Number
Other examples of Perfect Numbers: ... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/env python3
from .hash_table import HashTable
from .number_theory.prime_numbers import check_prime, next_prime
class DoubleHash(HashTable):
"""
Hash Table example with open addressing and Double Hash
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
de... | #!/usr/bin/env python3
from .hash_table import HashTable
from .number_theory.prime_numbers import check_prime, next_prime
class DoubleHash(HashTable):
"""
Hash Table example with open addressing and Double Hash
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
de... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
The Mandelbrot set is the set of complex numbers "c" for which the series
"z_(n+1) = z_n * z_n + c" does not diverge, i.e. remains bounded. Thus, a
complex number "c" is a member of the Mandelbrot set if, when starting with
"z_0 = 0" and applying the iteration repeatedly, the absolute value of
"z_n" remains bounded... | """
The Mandelbrot set is the set of complex numbers "c" for which the series
"z_(n+1) = z_n * z_n + c" does not diverge, i.e. remains bounded. Thus, a
complex number "c" is a member of the Mandelbrot set if, when starting with
"z_0 = 0" and applying the iteration repeatedly, the absolute value of
"z_n" remains bounded... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Author : Syed Faizan ( 3rd Year IIIT Pune )
Github : faizan2700
Purpose : You have one function f(x) which takes float integer and returns
float you have to integrate the function in limits a to b.
The approximation proposed by Thomas Simpsons in 1743 is one way to calculate
integration.
( read article : https://... | """
Author : Syed Faizan ( 3rd Year IIIT Pune )
Github : faizan2700
Purpose : You have one function f(x) which takes float integer and returns
float you have to integrate the function in limits a to b.
The approximation proposed by Thomas Simpsons in 1743 is one way to calculate
integration.
( read article : https://... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance"""
def jaro_winkler(str1: str, str2: str) -> float:
"""
Jaro–Winkler distance is a string metric measuring an edit distance between two
sequences.
Output value is between 0.0 and 1.0.
>>> jaro_winkler("martha", "marhta")
0.9611111... | """https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance"""
def jaro_winkler(str1: str, str2: str) -> float:
"""
Jaro–Winkler distance is a string metric measuring an edit distance between two
sequences.
Output value is between 0.0 and 1.0.
>>> jaro_winkler("martha", "marhta")
0.9611111... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Implements a disjoint set using Lists and some added heuristics for efficiency
Union by Rank Heuristic and Path Compression
"""
class DisjointSet:
def __init__(self, set_counts: list) -> None:
"""
Initialize with a list of the number of items in each set
and with rank = 1 for each set
... | """
Implements a disjoint set using Lists and some added heuristics for efficiency
Union by Rank Heuristic and Path Compression
"""
class DisjointSet:
def __init__(self, set_counts: list) -> None:
"""
Initialize with a list of the number of items in each set
and with rank = 1 for each set
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # Numbers of alphabet which we call base
alphabet_size = 256
# Modulus to hash a string
modulus = 1000003
def rabin_karp(pattern: str, text: str) -> bool:
"""
The Rabin-Karp Algorithm for finding a pattern within a piece of text
with complexity O(nm), most efficient when it is used with multiple patterns
... | # Numbers of alphabet which we call base
alphabet_size = 256
# Modulus to hash a string
modulus = 1000003
def rabin_karp(pattern: str, text: str) -> bool:
"""
The Rabin-Karp Algorithm for finding a pattern within a piece of text
with complexity O(nm), most efficient when it is used with multiple patterns
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Project Euler Problem 6: https://projecteuler.net/problem=6
Sum square difference
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of... | """
Project Euler Problem 6: https://projecteuler.net/problem=6
Sum square difference
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Implementation of gaussian filter algorithm
"""
from itertools import product
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import dot, exp, mgrid, pi, ravel, square, uint8, zeros
def gen_gaussian_kernel(k_size, sigma):
center = k_size // 2
x, y = mgrid[0 - center : k_size ... | """
Implementation of gaussian filter algorithm
"""
from itertools import product
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import dot, exp, mgrid, pi, ravel, square, uint8, zeros
def gen_gaussian_kernel(k_size, sigma):
center = k_size // 2
x, y = mgrid[0 - center : k_size ... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | def bubble_sort(collection):
"""Pure implementation of bubble sort algorithm in Python
:param collection: some mutable ordered collection with heterogeneous
comparable items inside
:return: the same collection ordered by ascending
Examples:
>>> bubble_sort([0, 5, 2, 3, 2])
[0, 2, 2, 3, 5]
... | def bubble_sort(collection):
"""Pure implementation of bubble sort algorithm in Python
:param collection: some mutable ordered collection with heterogeneous
comparable items inside
:return: the same collection ordered by ascending
Examples:
>>> bubble_sort([0, 5, 2, 3, 2])
[0, 2, 2, 3, 5]
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] 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/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | def printDist(dist, V):
print("\nVertex Distance")
for i in range(V):
if dist[i] != float("inf"):
print(i, "\t", int(dist[i]), end="\t")
else:
print(i, "\t", "INF", end="\t")
print()
def minDist(mdist, vset, V):
minVal = float("inf")
minInd = -1
for ... | def printDist(dist, V):
print("\nVertex Distance")
for i in range(V):
if dist[i] != float("inf"):
print(i, "\t", int(dist[i]), end="\t")
else:
print(i, "\t", "INF", end="\t")
print()
def minDist(mdist, vset, V):
minVal = float("inf")
minInd = -1
for ... | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.