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
9,358
Removed redundant greatest_common_divisor code
### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths folder. Fixes #8098 * [ ] Add an algorithm? *...
Siddikpatel
2023-10-02T05:03:50Z
2023-10-09T12:19:12Z
876087be998d5b366d68cbb9394b6b92b7f619f6
583a614fefaa9c932e6d650abfea2eaa75a93b05
Removed redundant greatest_common_divisor code. ### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths f...
""" Reference: https://www.investopedia.com/terms/p/presentvalue.asp An algorithm that calculates the present value of a stream of yearly cash flows given... 1. The discount rate (as a decimal, not a percent) 2. An array of cash flows, with the index of the cash flow being the associated year Note: This algorithm ass...
""" Reference: https://www.investopedia.com/terms/p/presentvalue.asp An algorithm that calculates the present value of a stream of yearly cash flows given... 1. The discount rate (as a decimal, not a percent) 2. An array of cash flows, with the index of the cash flow being the associated year Note: This algorithm ass...
-1
TheAlgorithms/Python
9,358
Removed redundant greatest_common_divisor code
### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths folder. Fixes #8098 * [ ] Add an algorithm? *...
Siddikpatel
2023-10-02T05:03:50Z
2023-10-09T12:19:12Z
876087be998d5b366d68cbb9394b6b92b7f619f6
583a614fefaa9c932e6d650abfea2eaa75a93b05
Removed redundant greatest_common_divisor code. ### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths f...
"""Prime Check.""" import math import unittest def is_prime(number: int) -> bool: """Checks to see if a number is a prime in O(sqrt(n)). A number is prime if it has exactly two factors: 1 and itself. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3...
"""Prime Check.""" import math import unittest def is_prime(number: int) -> bool: """Checks to see if a number is a prime in O(sqrt(n)). A number is prime if it has exactly two factors: 1 and itself. >>> is_prime(0) False >>> is_prime(1) False >>> is_prime(2) True >>> is_prime(3...
-1
TheAlgorithms/Python
9,358
Removed redundant greatest_common_divisor code
### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths folder. Fixes #8098 * [ ] Add an algorithm? *...
Siddikpatel
2023-10-02T05:03:50Z
2023-10-09T12:19:12Z
876087be998d5b366d68cbb9394b6b92b7f619f6
583a614fefaa9c932e6d650abfea2eaa75a93b05
Removed redundant greatest_common_divisor code. ### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths f...
JFIFC     C  "  L !1AQ"aq2 #BR$3bCr4DS %&5cs<!1AQ"...
JFIFC     C  "  L !1AQ"aq2 #BR$3bCr4DS %&5cs<!1AQ"...
-1
TheAlgorithms/Python
9,358
Removed redundant greatest_common_divisor code
### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths folder. Fixes #8098 * [ ] Add an algorithm? *...
Siddikpatel
2023-10-02T05:03:50Z
2023-10-09T12:19:12Z
876087be998d5b366d68cbb9394b6b92b7f619f6
583a614fefaa9c932e6d650abfea2eaa75a93b05
Removed redundant greatest_common_divisor code. ### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths f...
import itertools import string from collections.abc import Generator, Iterable def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]: it = iter(seq) while True: chunk = tuple(itertools.islice(it, size)) if not chunk: return yield chunk def p...
import itertools import string from collections.abc import Generator, Iterable def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]: it = iter(seq) while True: chunk = tuple(itertools.islice(it, size)) if not chunk: return yield chunk def p...
-1
TheAlgorithms/Python
9,358
Removed redundant greatest_common_divisor code
### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths folder. Fixes #8098 * [ ] Add an algorithm? *...
Siddikpatel
2023-10-02T05:03:50Z
2023-10-09T12:19:12Z
876087be998d5b366d68cbb9394b6b92b7f619f6
583a614fefaa9c932e6d650abfea2eaa75a93b05
Removed redundant greatest_common_divisor code. ### Describe your change: Previously all the files that needed greatest_common_divisor (aka gcd), used to define the method instead of just importing from Maths directory's greatest_common_divisor.py file. I removed thos definitions and imported gcd method from Maths f...
def quick_sort(data: list) -> list: """ >>> for data in ([2, 1, 0], [2.2, 1.1, 0], "quick_sort"): ... quick_sort(data) == sorted(data) True True True """ if len(data) <= 1: return data else: return [ *quick_sort([e for e in data[1:] if e <= data[0]]), ...
def quick_sort(data: list) -> list: """ >>> for data in ([2, 1, 0], [2.2, 1.1, 0], "quick_sort"): ... quick_sort(data) == sorted(data) True True True """ if len(data) <= 1: return data else: return [ *quick_sort([e for e in data[1:] if e <= data[0]]), ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Langton's ant @ https://en.wikipedia.org/wiki/Langton%27s_ant @ https://upload.wikimedia.org/wikipedia/commons/0/09/LangtonsAntAnimated.gif """ from functools import partial from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation WIDTH = 80 HEIGHT = 80 class LangtonsAnt: """ ...
""" Langton's ant @ https://en.wikipedia.org/wiki/Langton%27s_ant @ https://upload.wikimedia.org/wikipedia/commons/0/09/LangtonsAntAnimated.gif """ from functools import partial from matplotlib import pyplot as plt from matplotlib.animation import FuncAnimation WIDTH = 80 HEIGHT = 80 class LangtonsAnt: """ ...
1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# Compression Data compression is everywhere, you need it to store data without taking too much space. Either the compression lose some data (then we talk about lossy compression, such as .jpg) or it does not (and then it is lossless compression, such as .png) Lossless compression is mainly used for archive purpose a...
# Compression Data compression is everywhere, you need it to store data without taking too much space. Either the compression loses some data (then we talk about lossy compression, such as .jpg) or it does not (and then it is lossless compression, such as .png) Lossless compression is mainly used for archive purpose ...
1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# Hashes Hashing is the process of mapping any amount of data to a specified size using an algorithm. This is known as a hash value (or, if you're feeling fancy, a hash code, hash sums, or even a hash digest). Hashing is a one-way function, whereas encryption is a two-way function. While it is functionally conceivable ...
# Hashes Hashing is the process of mapping any amount of data to a specified size using an algorithm. This is known as a hash value (or, if you're feeling fancy, a hash code, hash sums, or even a hash digest). Hashing is a one-way function, whereas encryption is a two-way function. While it is functionally conceivable ...
1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# Sorting Algorithms Sorting is the process of putting data in a specific order. The way to arrange data in a specific order is specified by the sorting algorithm. The most typical orders are lexical or numerical. The significance of sorting lies in the fact that, if data is stored in a sorted manner, data searching ca...
# Sorting Algorithms Sorting is the process of putting data in a specific order. The way to arrange data in a specific order is specified by the sorting algorithm. The most typical orders are lexical or numerical. The significance of sorting lies in the fact that, if data is stored in a sorted manner, data searching ca...
1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def remove_duplicates(key: str) -> str: """ Removes duplicate alphabetic characters in a keyword (letter is ignored after its first appearance). :param key: Keyword to use :return: String with duplicates removed >>> remove_duplicates('Hello World!!') 'Helo Wrd' """ key_no_dups =...
def remove_duplicates(key: str) -> str: """ Removes duplicate alphabetic characters in a keyword (letter is ignored after its first appearance). :param key: Keyword to use :return: String with duplicates removed >>> remove_duplicates('Hello World!!') 'Helo Wrd' """ key_no_dups =...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Implemented an algorithm using opencv to convert a colored image into its negative """ from cv2 import destroyAllWindows, imread, imshow, waitKey def convert_to_negative(img): # getting number of pixels in the image pixel_h, pixel_v = img.shape[0], img.shape[1] # converting each pixel's color to ...
""" Implemented an algorithm using opencv to convert a colored image into its negative """ from cv2 import destroyAllWindows, imread, imshow, waitKey def convert_to_negative(img): # getting number of pixels in the image pixel_h, pixel_v = img.shape[0], img.shape[1] # converting each pixel's color to ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" This function implements the shell sort algorithm which is slightly faster than its pure implementation. This shell sort is implemented using a gap, which shrinks by a certain factor each iteration. In this implementation, the gap is initially set to the length of the collection. The gap is then reduced by a certa...
""" This function implements the shell sort algorithm which is slightly faster than its pure implementation. This shell sort is implemented using a gap, which shrinks by a certain factor each iteration. In this implementation, the gap is initially set to the length of the collection. The gap is then reduced by a certa...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Problem 78 Url: https://projecteuler.net/problem=78 Statement: Let p(n) represent the number of different ways in which n coins can be separated into piles. For example, five coins can be separated into piles in exactly seven different ways, so p(5)=7. OOOOO OOOO O OOO OO ...
""" Problem 78 Url: https://projecteuler.net/problem=78 Statement: Let p(n) represent the number of different ways in which n coins can be separated into piles. For example, five coins can be separated into piles in exactly seven different ways, so p(5)=7. OOOOO OOOO O OOO OO ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" 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
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from bisect import bisect from itertools import accumulate def frac_knapsack(vl, wt, w, n): """ >>> frac_knapsack([60, 100, 120], [10, 20, 30], 50, 3) 240.0 """ r = sorted(zip(vl, wt), key=lambda x: x[0] / x[1], reverse=True) vl, wt = [i[0] for i in r], [i[1] for i in r] acc = list(accumu...
from bisect import bisect from itertools import accumulate def frac_knapsack(vl, wt, w, n): """ >>> frac_knapsack([60, 100, 120], [10, 20, 30], 50, 3) 240.0 """ r = sorted(zip(vl, wt), key=lambda x: x[0] / x[1], reverse=True) vl, wt = [i[0] for i in r], [i[1] for i in r] acc = list(accumu...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def alternative_string_arrange(first_str: str, second_str: str) -> str: """ Return the alternative arrangements of the two strings. :param first_str: :param second_str: :return: String >>> alternative_string_arrange("ABCD", "XY") 'AXBYCD' >>> alternative_string_arrange("XY", "ABCD") ...
def alternative_string_arrange(first_str: str, second_str: str) -> str: """ Return the alternative arrangements of the two strings. :param first_str: :param second_str: :return: String >>> alternative_string_arrange("ABCD", "XY") 'AXBYCD' >>> alternative_string_arrange("XY", "ABCD") ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. ""...
""" The sum-of-subsetsproblem states that a set of non-negative integers, and a value M, determine all possible subsets of the given set whose summation sum equal to given M. Summation of the chosen numbers must be equal to given number M and one number can be used only once. ""...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_...
""" Pure Python implementation of a binary search algorithm. For doctests run following command: python3 -m doctest -v simple_binary_search.py For manual testing run: python3 simple_binary_search.py """ from __future__ import annotations def binary_search(a_list: list[int], item: int) -> bool: """ >>> test_...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# https://en.wikipedia.org/wiki/Simulated_annealing import math import random from typing import Any from .hill_climbing import SearchProblem def simulated_annealing( search_prob, find_max: bool = True, max_x: float = math.inf, min_x: float = -math.inf, max_y: float = math.inf, min_y: float =...
# https://en.wikipedia.org/wiki/Simulated_annealing import math import random from typing import Any from .hill_climbing import SearchProblem def simulated_annealing( search_prob, find_max: bool = True, max_x: float = math.inf, min_x: float = -math.inf, max_y: float = math.inf, min_y: float =...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
#!/usr/bin/env python3 """ Simulation of the Quantum Key Distribution (QKD) protocol called BB84, created by Charles Bennett and Gilles Brassard in 1984. BB84 is a key-distribution protocol that ensures secure key distribution using qubits instead of classical bits. The generated key is the result of simulating a quan...
#!/usr/bin/env python3 """ Simulation of the Quantum Key Distribution (QKD) protocol called BB84, created by Charles Bennett and Gilles Brassard in 1984. BB84 is a key-distribution protocol that ensures secure key distribution using qubits instead of classical bits. The generated key is the result of simulating a quan...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Signum function -- https://en.wikipedia.org/wiki/Sign_function """ def signum(num: float) -> int: """ Applies signum function on the number >>> signum(-10) -1 >>> signum(10) 1 >>> signum(0) 0 """ if num < 0: return -1 return 1 if num else 0 def test_signum() ...
""" Signum function -- https://en.wikipedia.org/wiki/Sign_function """ def signum(num: float) -> int: """ Applies signum function on the number >>> signum(-10) -1 >>> signum(10) 1 >>> signum(0) 0 """ if num < 0: return -1 return 1 if num else 0 def test_signum() ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def is_int_palindrome(num: int) -> bool: """ Returns whether `num` is a palindrome or not (see for reference https://en.wikipedia.org/wiki/Palindromic_number). >>> is_int_palindrome(-121) False >>> is_int_palindrome(0) True >>> is_int_palindrome(10) False >>> is_int_palindrome(1...
def is_int_palindrome(num: int) -> bool: """ Returns whether `num` is a palindrome or not (see for reference https://en.wikipedia.org/wiki/Palindromic_number). >>> is_int_palindrome(-121) False >>> is_int_palindrome(0) True >>> is_int_palindrome(10) False >>> is_int_palindrome(1...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
#!/usr/bin/env python3 """ Davis–Putnam–Logemann–Loveland (DPLL) algorithm is a complete, backtracking-based search algorithm for deciding the satisfiability of propositional logic formulae in conjunctive normal form, i.e, for solving the Conjunctive Normal Form SATisfiability (CNF-SAT) problem. For more information ...
#!/usr/bin/env python3 """ Davis–Putnam–Logemann–Loveland (DPLL) algorithm is a complete, backtracking-based search algorithm for deciding the satisfiability of propositional logic formulae in conjunctive normal form, i.e, for solving the Conjunctive Normal Form SATisfiability (CNF-SAT) problem. For more information ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def test_prim_successful_result(): num_nodes, num_edges = 9, 14 # noqa: F841 edges = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], ...
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def test_prim_successful_result(): num_nodes, num_edges = 9, 14 # noqa: F841 edges = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from __future__ import annotations def find_max_iterative(nums: list[int | float]) -> int | float: """ >>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]): ... find_max_iterative(nums) == max(nums) True True True True >>> find_max_iterative([2, 4, 9, 7, 19, 94, 5...
from __future__ import annotations def find_max_iterative(nums: list[int | float]) -> int | float: """ >>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]): ... find_max_iterative(nums) == max(nums) True True True True >>> find_max_iterative([2, 4, 9, 7, 19, 94, 5...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Project Euler Problem 10: https://projecteuler.net/problem=10 Summation of primes The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. References: - https://en.wikipedia.org/wiki/Prime_number """ import math from collections.abc import Iterator from itertoo...
""" Project Euler Problem 10: https://projecteuler.net/problem=10 Summation of primes The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. References: - https://en.wikipedia.org/wiki/Prime_number """ import math from collections.abc import Iterator from itertoo...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# Conversion Conversion programs convert a type of data, a number from a numerical base or unit into one of another type, base or unit, e.g. binary to decimal, integer to string or foot to meters. * <https://en.wikipedia.org/wiki/Data_conversion> * <https://en.wikipedia.org/wiki/Transcoding>
# Conversion Conversion programs convert a type of data, a number from a numerical base or unit into one of another type, base or unit, e.g. binary to decimal, integer to string or foot to meters. * <https://en.wikipedia.org/wiki/Data_conversion> * <https://en.wikipedia.org/wiki/Transcoding>
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# https://en.wikipedia.org/wiki/Charge_carrier_density # https://www.pveducation.org/pvcdrom/pn-junctions/equilibrium-carrier-concentration # http://www.ece.utep.edu/courses/ee3329/ee3329/Studyguide/ToC/Fundamentals/Carriers/concentrations.html from __future__ import annotations def carrier_concentration( electr...
# https://en.wikipedia.org/wiki/Charge_carrier_density # https://www.pveducation.org/pvcdrom/pn-junctions/equilibrium-carrier-concentration # http://www.ece.utep.edu/courses/ee3329/ee3329/Studyguide/ToC/Fundamentals/Carriers/concentrations.html from __future__ import annotations def carrier_concentration( electr...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
# Binary Tree Traversal ## Overview The combination of binary trees being data structures and traversal being an algorithm relates to classic problems, either directly or indirectly. > If you can grasp the traversal of binary trees, the traversal of other complicated trees will be easy for you. The following are so...
# Binary Tree Traversal ## Overview The combination of binary trees being data structures and traversal being an algorithm relates to classic problems, either directly or indirectly. > If you can grasp the traversal of binary trees, the traversal of other complicated trees will be easy for you. The following are so...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from typing import Literal LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def translate_message( key: str, message: str, mode: Literal["encrypt", "decrypt"] ) -> str: """ >>> translate_message("QWERTYUIOPASDFGHJKLZXCVBNM","Hello World","encrypt") 'Pcssi Bidsm' """ chars_a = LETTERS if mode == "decryp...
from typing import Literal LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def translate_message( key: str, message: str, mode: Literal["encrypt", "decrypt"] ) -> str: """ >>> translate_message("QWERTYUIOPASDFGHJKLZXCVBNM","Hello World","encrypt") 'Pcssi Bidsm' """ chars_a = LETTERS if mode == "decryp...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Minimax helps to achieve maximum score in a game by checking all possible moves. """ from __future__ import annotations import math def minimax( depth: int, node_index: int, is_max: bool, scores: list[int], height: float ) -> int: """ depth is current depth in game tree. node_index is index of c...
""" Minimax helps to achieve maximum score in a game by checking all possible moves. """ from __future__ import annotations import math def minimax( depth: int, node_index: int, is_max: bool, scores: list[int], height: float ) -> int: """ depth is current depth in game tree. node_index is index of c...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
import argparse import datetime def zeller(date_input: str) -> str: """ Zellers Congruence Algorithm Find the day of the week for nearly any Gregorian or Julian calendar date >>> zeller('01-31-2010') 'Your date 01-31-2010, is a Sunday!' Validate out of range month >>> zeller('13-31-2010'...
import argparse import datetime def zeller(date_input: str) -> str: """ Zellers Congruence Algorithm Find the day of the week for nearly any Gregorian or Julian calendar date >>> zeller('01-31-2010') 'Your date 01-31-2010, is a Sunday!' Validate out of range month >>> zeller('13-31-2010'...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Project Euler Problem 100: https://projecteuler.net/problem=100 If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21) x (14/20) = 1/2. The next such arrangemen...
""" Project Euler Problem 100: https://projecteuler.net/problem=100 If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the probability of taking two blue discs, P(BB) = (15/21) x (14/20) = 1/2. The next such arrangemen...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Given the root of a binary tree and an integer target, find the number of paths where the sum of the values along the path equals target. Leetcode reference: https://leetcode.com/problems/path-sum-iii/ """ from __future__ import annotations class Node: """ A Node has value variable and pointers to Node...
""" Given the root of a binary tree and an integer target, find the number of paths where the sum of the values along the path equals target. Leetcode reference: https://leetcode.com/problems/path-sum-iii/ """ from __future__ import annotations class Node: """ A Node has value variable and pointers to Node...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from __future__ import annotations import pandas as pd def calculate_waitingtime( arrival_time: list[int], burst_time: list[int], no_of_processes: int ) -> list[int]: """ Calculate the wai...
""" Shortest job remaining first Please note arrival time and burst Please use spaces to separate times entered. """ from __future__ import annotations import pandas as pd def calculate_waitingtime( arrival_time: list[int], burst_time: list[int], no_of_processes: int ) -> list[int]: """ Calculate the wai...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def reverse_letters(input_str: str) -> str: """ Reverses letters in a given string without adjusting the position of the words >>> reverse_letters('The cat in the hat') 'ehT tac ni eht tah' >>> reverse_letters('The quick brown fox jumped over the lazy dog.') 'ehT kciuq nworb xof depmuj revo eht ...
def reverse_letters(input_str: str) -> str: """ Reverses letters in a given string without adjusting the position of the words >>> reverse_letters('The cat in the hat') 'ehT tac ni eht tah' >>> reverse_letters('The quick brown fox jumped over the lazy dog.') 'ehT kciuq nworb xof depmuj revo eht ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def perfect_cube(n: int) -> bool: """ Check if a number is a perfect cube or not. >>> perfect_cube(27) True >>> perfect_cube(4) False """ val = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
def perfect_cube(n: int) -> bool: """ Check if a number is a perfect cube or not. >>> perfect_cube(27) True >>> perfect_cube(4) False """ val = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Project Euler Problem 493: https://projecteuler.net/problem=493 70 coloured balls are placed in an urn, 10 for each of the seven rainbow colours. What is the expected number of distinct colours in 20 randomly picked balls? Give your answer with nine digits after the decimal point (a.bcdefghij). ----- This combin...
""" Project Euler Problem 493: https://projecteuler.net/problem=493 70 coloured balls are placed in an urn, 10 for each of the seven rainbow colours. What is the expected number of distinct colours in 20 randomly picked balls? Give your answer with nine digits after the decimal point (a.bcdefghij). ----- This combin...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
total_users,total_events,days 18231,0.0,1 22621,1.0,2 15675,0.0,3 23583,1.0,4 68351,5.0,5 34338,3.0,6 19238,0.0,0 24192,0.0,1 70349,0.0,2 103510,0.0,3 128355,1.0,4 148484,6.0,5 153489,3.0,6 162667,1.0,0 311430,3.0,1 435663,7.0,2 273526,0.0,3 628588,2.0,4 454989,13.0,5 539040,3.0,6 52974,1.0,0 103451,2.0,1 810020,5.0,2 ...
total_users,total_events,days 18231,0.0,1 22621,1.0,2 15675,0.0,3 23583,1.0,4 68351,5.0,5 34338,3.0,6 19238,0.0,0 24192,0.0,1 70349,0.0,2 103510,0.0,3 128355,1.0,4 148484,6.0,5 153489,3.0,6 162667,1.0,0 311430,3.0,1 435663,7.0,2 273526,0.0,3 628588,2.0,4 454989,13.0,5 539040,3.0,6 52974,1.0,0 103451,2.0,1 810020,5.0,2 ...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from __future__ import annotations class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Node | None = None self.right: Node | None = None def display(tree: Node | None) ->...
from __future__ import annotations class Node: """ A Node has data variable and pointers to Nodes to its left and right. """ def __init__(self, data: int) -> None: self.data = data self.left: Node | None = None self.right: Node | None = None def display(tree: Node | None) ->...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
def bin_exp_mod(a, n, b): """ >>> bin_exp_mod(3, 4, 5) 1 >>> bin_exp_mod(7, 13, 10) 7 """ # mod b assert b != 0, "This cannot accept modulo that is == 0" if n == 0: return 1 if n % 2 == 1: return (bin_exp_mod(a, n - 1, b) * a) % b r = bin_exp_mod(a, n / 2, b...
def bin_exp_mod(a, n, b): """ >>> bin_exp_mod(3, 4, 5) 1 >>> bin_exp_mod(7, 13, 10) 7 """ # mod b assert b != 0, "This cannot accept modulo that is == 0" if n == 0: return 1 if n % 2 == 1: return (bin_exp_mod(a, n - 1, b) * a) % b r = bin_exp_mod(a, n / 2, b...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
""" A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
from math import factorial """ https://en.wikipedia.org/wiki/Automatic_differentiation#Automatic_differentiation_using_dual_numbers https://blog.jliszka.org/2013/10/24/exact-numeric-nth-derivatives.html Note this only works for basic functions, f(x) where the power of x is positive. """ class Dual: def __init__...
from math import factorial """ https://en.wikipedia.org/wiki/Automatic_differentiation#Automatic_differentiation_using_dual_numbers https://blog.jliszka.org/2013/10/24/exact-numeric-nth-derivatives.html Note this only works for basic functions, f(x) where the power of x is positive. """ class Dual: def __init__...
-1
TheAlgorithms/Python
9,076
Fix typos
* [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
omahs
2023-09-22T13:22:15Z
2023-09-23T08:53:09Z
dc50add8a78ebf34bc7bb050c1a0e61d207b9544
b203150ac481743a6d8c1ef01091712a54dfbf6c
Fix typos. * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change?
""" Project Euler Problem 234: https://projecteuler.net/problem=234 For any integer n, consider the three functions f1,n(x,y,z) = x^(n+1) + y^(n+1) - z^(n+1) f2,n(x,y,z) = (xy + yz + zx)*(x^(n-1) + y^(n-1) - z^(n-1)) f3,n(x,y,z) = xyz*(xn-2 + yn-2 - zn-2) and their combination fn(x,y,z) = f1,n(x,y,z) + f2,n(x,y,z) ...
""" Project Euler Problem 234: https://projecteuler.net/problem=234 For any integer n, consider the three functions f1,n(x,y,z) = x^(n+1) + y^(n+1) - z^(n+1) f2,n(x,y,z) = (xy + yz + zx)*(x^(n-1) + y^(n-1) - z^(n-1)) f3,n(x,y,z) = xyz*(xn-2 + yn-2 - zn-2) and their combination fn(x,y,z) = f1,n(x,y,z) + f2,n(x,y,z) ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
## Arithmetic Analysis * [Bisection](arithmetic_analysis/bisection.py) * [Gaussian Elimination](arithmetic_analysis/gaussian_elimination.py) * [In Static Equilibrium](arithmetic_analysis/in_static_equilibrium.py) * [Intersection](arithmetic_analysis/intersection.py) * [Jacobi Iteration Method](arithmetic_ana...
## Arithmetic Analysis * [Bisection](arithmetic_analysis/bisection.py) * [Gaussian Elimination](arithmetic_analysis/gaussian_elimination.py) * [In Static Equilibrium](arithmetic_analysis/in_static_equilibrium.py) * [Intersection](arithmetic_analysis/intersection.py) * [Jacobi Iteration Method](arithmetic_ana...
1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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/Image_texture https://en.wikipedia.org/wiki/Co-occurrence_matrix#Application_to_image_analysis """ import imageio.v2 as imageio import numpy as np def root_mean_square_error(original: np.ndarray, reference: np.ndarray) -> float: """Simple implementation of Root Mean Squared Error...
""" https://en.wikipedia.org/wiki/Image_texture https://en.wikipedia.org/wiki/Co-occurrence_matrix#Application_to_image_analysis """ import imageio.v2 as imageio import numpy as np def root_mean_square_error(original: np.ndarray, reference: np.ndarray) -> float: """Simple implementation of Root Mean Squared Error...
1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
from enum import Enum from typing import ClassVar, Literal class NumberingSystem(Enum): SHORT = ( (15, "quadrillion"), (12, "trillion"), (9, "billion"), (6, "million"), (3, "thousand"), (2, "hundred"), ) LONG = ( (15, "billiard"), (9, "milli...
from enum import Enum from typing import ClassVar, Literal class NumberingSystem(Enum): SHORT = ( (15, "quadrillion"), (12, "trillion"), (9, "billion"), (6, "million"), (3, "thousand"), (2, "hundred"), ) LONG = ( (15, "billiard"), (9, "milli...
1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We t...
from collections import deque def tarjan(g): """ Tarjan's algo for finding strongly connected components in a directed graph Uses two main attributes of each node to track reachability, the index of that node within a component(index), and the lowest index reachable from that node(lowlink). We t...
1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Given an integer n, we have to find the nth ugly number. For more details, refer this article https://www.geeksforgeeks.org/ugly-numbers...
""" Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly numbers. By convention, 1 is included. Given an integer n, we have to find the nth ugly number. For more details, refer this article https://www.geeksforgeeks.org/ugly-numbers...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" Peak signal-to-noise ratio - PSNR https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio Source: https://tutorials.techonical.com/how-to-calculate-psnr-value-of-two-images-using-python """ import math import os import cv2 import numpy as np PIXEL_MAX = 255.0 def peak_signal_to_noise_ratio(original: float...
""" Peak signal-to-noise ratio - PSNR https://en.wikipedia.org/wiki/Peak_signal-to-noise_ratio Source: https://tutorials.techonical.com/how-to-calculate-psnr-value-of-two-images-using-python """ import math import os import cv2 import numpy as np PIXEL_MAX = 255.0 def peak_signal_to_noise_ratio(original: float...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 script demonstrates the implementation of the Sigmoid Linear Unit (SiLU) or swish function. * https://en.wikipedia.org/wiki/Rectifier_(neural_networks) * https://en.wikipedia.org/wiki/Swish_function The function takes a vector x of K real numbers as input and returns x * sigmoid(x). Swish is a smooth, non-mon...
""" This script demonstrates the implementation of the Sigmoid Linear Unit (SiLU) or swish function. * https://en.wikipedia.org/wiki/Rectifier_(neural_networks) * https://en.wikipedia.org/wiki/Swish_function The function takes a vector x of K real numbers as input and returns x * sigmoid(x). Swish is a smooth, non-mon...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 itertools import string from collections.abc import Generator, Iterable def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]: it = iter(seq) while True: chunk = tuple(itertools.islice(it, size)) if not chunk: return yield chunk def p...
import itertools import string from collections.abc import Generator, Iterable def chunker(seq: Iterable[str], size: int) -> Generator[tuple[str, ...], None, None]: it = iter(seq) while True: chunk = tuple(itertools.islice(it, size)) if not chunk: return yield chunk def p...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 sys def minimum_subarray_sum(target: int, numbers: list[int]) -> int: """ Return the length of the shortest contiguous subarray in a list of numbers whose sum is at least target. Reference: https://stackoverflow.com/questions/8269916 >>> minimum_subarray_sum(7, [2, 3, 1, 2, 4, 3]) 2 >...
import sys def minimum_subarray_sum(target: int, numbers: list[int]) -> int: """ Return the length of the shortest contiguous subarray in a list of numbers whose sum is at least target. Reference: https://stackoverflow.com/questions/8269916 >>> minimum_subarray_sum(7, [2, 3, 1, 2, 4, 3]) 2 >...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 73: https://projecteuler.net/problem=73 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, 2/7, ...
""" Project Euler Problem 73: https://projecteuler.net/problem=73 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, 2/7, ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" What is the greatest product of four adjacent numbers (horizontally, vertically, or diagonally) in this 20x20 array? 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 ...
""" What is the greatest product of four adjacent numbers (horizontally, vertically, or diagonally) in this 20x20 array? 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
from graphs.minimum_spanning_tree_kruskal import kruskal def test_kruskal_successful_result(): num_nodes = 9 edges = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], [2, 3, 7], [2, 5, 4], [6, 5, 2], ...
from graphs.minimum_spanning_tree_kruskal import kruskal def test_kruskal_successful_result(): num_nodes = 9 edges = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], [2, 3, 7], [2, 5, 4], [6, 5, 2], ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 82: https://projecteuler.net/problem=82 The minimal path sum in the 5 by 5 matrix below, by starting in any cell in the left column and finishing in any cell in the right column, and only moving up, down, and right, is indicated in red and bold; the sum is equal to 994. 131 673 [23...
""" Project Euler Problem 82: https://projecteuler.net/problem=82 The minimal path sum in the 5 by 5 matrix below, by starting in any cell in the left column and finishing in any cell in the right column, and only moving up, down, and right, is indicated in red and bold; the sum is equal to 994. 131 673 [23...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2**6972593 − 1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2**p − 1, have been found which contain more digits. However, in 2004 there was found a massive n...
""" The first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2**6972593 − 1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2**p − 1, have been found which contain more digits. However, in 2004 there was found a massive n...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 NOT Gate is a logic gate in boolean algebra which results to 0 (False) if the input is high, and 1 (True) if the input is low. Following is the truth table of a XOR Gate: ------------------------------ | Input | Output | ------------------------------ | 0 | 1 | | 1 | 0 ...
""" A NOT Gate is a logic gate in boolean algebra which results to 0 (False) if the input is high, and 1 (True) if the input is low. Following is the truth table of a XOR Gate: ------------------------------ | Input | Output | ------------------------------ | 0 | 1 | | 1 | 0 ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 75: https://projecteuler.net/problem=75 It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples. 12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17...
""" Project Euler Problem 75: https://projecteuler.net/problem=75 It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples. 12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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: Phyllipe Bezerra (https://github.com/pmba) clothes = { 0: "underwear", 1: "pants", 2: "belt", 3: "suit", 4: "shoe", 5: "socks", 6: "shirt", 7: "tie", 8: "watch", } graph = [[1, 4], [2, 4], [3], [], [], [4], [2, 7], [3], []] visited = [0 for x in range(len(graph))] stack ...
# Author: Phyllipe Bezerra (https://github.com/pmba) clothes = { 0: "underwear", 1: "pants", 2: "belt", 3: "suit", 4: "shoe", 5: "socks", 6: "shirt", 7: "tie", 8: "watch", } graph = [[1, 4], [2, 4], [3], [], [], [4], [2, 7], [3], []] visited = [0 for x in range(len(graph))] stack ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" An implementation of Karger's Algorithm for partitioning a graph. """ from __future__ import annotations import random # Adjacency list representation of this graph: # https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg TEST_GRAPH = { "1": ["2", "3", "4", "5"], "2": ["1...
""" An implementation of Karger's Algorithm for partitioning a graph. """ from __future__ import annotations import random # Adjacency list representation of this graph: # https://en.wikipedia.org/wiki/File:Single_run_of_Karger%E2%80%99s_Mincut_algorithm.svg TEST_GRAPH = { "1": ["2", "3", "4", "5"], "2": ["1...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 Base 10 (Decimal) Values to Hexadecimal Representations """ # set decimal value for each hexadecimal digit values = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "a", 11: "b", 12: "c", 13: "d", 14: "e", ...
""" Convert Base 10 (Decimal) Values to Hexadecimal Representations """ # set decimal value for each hexadecimal digit values = { 0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10: "a", 11: "b", 12: "c", 13: "d", 14: "e", ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 an is valid email address algorithm @ https://en.wikipedia.org/wiki/Email_address """ import string email_tests: tuple[tuple[str, bool], ...] = ( ("simple@example.com", True), ("very.common@example.com", True), ("disposable.style.email.with+symbol@example.com", True), ("other-email-wit...
""" Implements an is valid email address algorithm @ https://en.wikipedia.org/wiki/Email_address """ import string email_tests: tuple[tuple[str, bool], ...] = ( ("simple@example.com", True), ("very.common@example.com", True), ("disposable.style.email.with+symbol@example.com", True), ("other-email-wit...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" guess the number using lower,higher and the value to find or guess solution works by dividing lower and higher of number guessed suppose lower is 0, higher is 1000 and the number to guess is 355 >>> guess_the_number(10, 1000, 17) started... guess the number : 17 details : [505, 257, 133, 71, 40, 25, 17] """ d...
""" guess the number using lower,higher and the value to find or guess solution works by dividing lower and higher of number guessed suppose lower is 0, higher is 1000 and the number to guess is 355 >>> guess_the_number(10, 1000, 17) started... guess the number : 17 details : [505, 257, 133, 71, 40, 25, 17] """ d...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 pure Python implementation of fibonacci search. Resources used: https://en.wikipedia.org/wiki/Fibonacci_search_technique For doctests run following command: python3 -m doctest -v fibonacci_search.py For manual testing run: python3 fibonacci_search.py """ from functools import lru_cache @lru_cache def f...
""" This is pure Python implementation of fibonacci search. Resources used: https://en.wikipedia.org/wiki/Fibonacci_search_technique For doctests run following command: python3 -m doctest -v fibonacci_search.py For manual testing run: python3 fibonacci_search.py """ from functools import lru_cache @lru_cache def f...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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/Lowest_common_ancestor # https://en.wikipedia.org/wiki/Breadth-first_search from __future__ import annotations from queue import Queue def swap(a: int, b: int) -> tuple[int, int]: """ Return a tuple (b, a) when given two integers a and b >>> swap(2,3) (3, 2) >>> s...
# https://en.wikipedia.org/wiki/Lowest_common_ancestor # https://en.wikipedia.org/wiki/Breadth-first_search from __future__ import annotations from queue import Queue def swap(a: int, b: int) -> tuple[int, int]: """ Return a tuple (b, a) when given two integers a and b >>> swap(2,3) (3, 2) >>> s...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 alternative_list_arrange(first_input_list: list, second_input_list: list) -> list: """ The method arranges two lists as one list in alternative forms of the list elements. :param first_input_list: :param second_input_list: :return: List >>> alternative_list_arrange([1, 2, 3, 4, 5], ["A", "B"...
def alternative_list_arrange(first_input_list: list, second_input_list: list) -> list: """ The method arranges two lists as one list in alternative forms of the list elements. :param first_input_list: :param second_input_list: :return: List >>> alternative_list_arrange([1, 2, 3, 4, 5], ["A", "B"...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 script demonstrates an implementation of the Gaussian Error Linear Unit function. * https://en.wikipedia.org/wiki/Activation_function#Comparison_of_activation_functions The function takes a vector of K real numbers as input and returns x * sigmoid(1.702*x). Gaussian Error Linear Unit (GELU) is a high-performi...
""" This script demonstrates an implementation of the Gaussian Error Linear Unit function. * https://en.wikipedia.org/wiki/Activation_function#Comparison_of_activation_functions The function takes a vector of K real numbers as input and returns x * sigmoid(1.702*x). Gaussian Error Linear Unit (GELU) is a high-performi...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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: Christian Bender date: 21.12.2017 class: XORCipher This class implements the XOR-cipher algorithm and provides some useful methods for encrypting and decrypting strings and files. Overview about methods - encrypt : list of char - dec...
""" author: Christian Bender date: 21.12.2017 class: XORCipher This class implements the XOR-cipher algorithm and provides some useful methods for encrypting and decrypting strings and files. Overview about methods - encrypt : list of char - dec...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width...
# @Author : lightXu # @File : convolve.py # @Time : 2019/7/8 0008 下午 16:13 from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import array, dot, pad, ravel, uint8, zeros def im2col(image, block_size): rows, cols = image.shape dst_height = cols - block_size[1] + 1 dst_width...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 is_palindrome(head): if not head: return True # split the list to two parts fast, slow = head.next, head while fast and fast.next: fast = fast.next.next slow = slow.next second = slow.next slow.next = None # Don't forget here! But forget still works! # reverse th...
def is_palindrome(head): if not head: return True # split the list to two parts fast, slow = head.next, head while fast and fast.next: fast = fast.next.next slow = slow.next second = slow.next slow.next = None # Don't forget here! But forget still works! # reverse th...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" Wikipedia: https://en.wikipedia.org/wiki/Enigma_machine Video explanation: https://youtu.be/QwQVMqfoB2E Also check out Numberphile's and Computerphile's videos on this topic This module contains function 'enigma' which emulates the famous Enigma machine from WWII. Module includes: - enigma function - showcase of f...
""" Wikipedia: https://en.wikipedia.org/wiki/Enigma_machine Video explanation: https://youtu.be/QwQVMqfoB2E Also check out Numberphile's and Computerphile's videos on this topic This module contains function 'enigma' which emulates the famous Enigma machine from WWII. Module includes: - enigma function - showcase of f...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 double ended queue. """ from __future__ import annotations from collections.abc import Iterable from dataclasses import dataclass from typing import Any class Deque: """ Deque data structure. Operations ---------- append(val: Any) -> None appendleft(val: Any) -> None ...
""" Implementation of double ended queue. """ from __future__ import annotations from collections.abc import Iterable from dataclasses import dataclass from typing import Any class Deque: """ Deque data structure. Operations ---------- append(val: Any) -> None appendleft(val: Any) -> None ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
""" By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 ...
""" By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 ...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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...
hex_table = {hex(i)[2:]: i for i in range(16)} # Use [:2] to strip off the leading '0x' def hex_to_decimal(hex_string: str) -> int: """ Convert a hexadecimal value to its decimal equivalent #https://www.programiz.com/python-programming/methods/built-in/hex >>> hex_to_decimal("a") 10 >>> hex_...
hex_table = {hex(i)[2:]: i for i in range(16)} # Use [:2] to strip off the leading '0x' def hex_to_decimal(hex_string: str) -> int: """ Convert a hexadecimal value to its decimal equivalent #https://www.programiz.com/python-programming/methods/built-in/hex >>> hex_to_decimal("a") 10 >>> hex_...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each buc...
#!/usr/bin/env python3 """ Illustrate how to implement bucket sort algorithm. Author: OMKAR PATHAK This program will illustrate how to implement bucket sort algorithm Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works by distributing the elements of an array into a number of buckets. Each buc...
-1
TheAlgorithms/Python
9,062
Delete empty junk file
### Describe your change: Delete empty file introduced in #9046 * [ ] 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 requ...
tianyizheng02
2023-09-16T18:59:42Z
2023-09-16T22:12:31Z
1488cdea708485eb1d81c73126eab13cb9b04a47
fbad85d3ecbbb826a5891807c823149d38bbaed3
Delete empty junk file. ### Describe your change: Delete empty file introduced in #9046 * [ ] 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 random from .binary_exp_mod import bin_exp_mod # This is a probabilistic check to test primality, useful for big numbers! # if it's a prime, it will return true # if it's not a prime, the chance of it returning true is at most 1/4**prec def is_prime_big(n, prec=1000): """ >>> from maths.prime_check im...
import random from .binary_exp_mod import bin_exp_mod # This is a probabilistic check to test primality, useful for big numbers! # if it's a prime, it will return true # if it's not a prime, the chance of it returning true is at most 1/4**prec def is_prime_big(n, prec=1000): """ >>> from maths.prime_check im...
-1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
## Arithmetic Analysis * [Bisection](arithmetic_analysis/bisection.py) * [Gaussian Elimination](arithmetic_analysis/gaussian_elimination.py) * [In Static Equilibrium](arithmetic_analysis/in_static_equilibrium.py) * [Intersection](arithmetic_analysis/intersection.py) * [Jacobi Iteration Method](arithmetic_ana...
## Arithmetic Analysis * [Bisection](arithmetic_analysis/bisection.py) * [Gaussian Elimination](arithmetic_analysis/gaussian_elimination.py) * [In Static Equilibrium](arithmetic_analysis/in_static_equilibrium.py) * [Intersection](arithmetic_analysis/intersection.py) * [Jacobi Iteration Method](arithmetic_ana...
1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
from __future__ import annotations def find_max(nums: list[int | float]) -> int | float: """ >>> 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 >>> find_max([2, 4, 9, 7, 19, 94, 5]) 94 >>> find_max([])...
from __future__ import annotations def find_max_iterative(nums: list[int | float]) -> int | float: """ >>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]): ... find_max_iterative(nums) == max(nums) True True True True >>> find_max_iterative([2, 4, 9, 7, 19, 94, 5...
1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
from __future__ import annotations def find_min(nums: list[int | float]) -> int | float: """ Find Minimum Number in a List :param nums: contains elements :return: min number in list >>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]): ... find_min(nums) == min(nums) ...
from __future__ import annotations def find_min_iterative(nums: list[int | float]) -> int | float: """ Find Minimum Number in a List :param nums: contains elements :return: min number in list >>> for nums in ([3, 2, 1], [-3, -2, -1], [3, -3, 0], [3.0, 3.1, 2.9]): ... find_min_iterative(nu...
1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
""" Project Euler Problem 104 : https://projecteuler.net/problem=104 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. It turns out that F541, which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all ...
""" Project Euler Problem 104 : https://projecteuler.net/problem=104 The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. It turns out that F541, which contains 113 digits, is the first Fibonacci number for which the last nine digits are 1-9 pandigital (contain all ...
-1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
""" This script demonstrates the implementation of the Sigmoid Linear Unit (SiLU) or swish function. * https://en.wikipedia.org/wiki/Rectifier_(neural_networks) * https://en.wikipedia.org/wiki/Swish_function The function takes a vector x of K real numbers as input and returns x * sigmoid(x). Swish is a smooth, non-mon...
""" This script demonstrates the implementation of the Sigmoid Linear Unit (SiLU) or swish function. * https://en.wikipedia.org/wiki/Rectifier_(neural_networks) * https://en.wikipedia.org/wiki/Swish_function The function takes a vector x of K real numbers as input and returns x * sigmoid(x). Swish is a smooth, non-mon...
-1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
""" Project Euler Problem 5: https://projecteuler.net/problem=5 Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is _evenly divisible_ by all of the numbers from 1 to 20? References: - https://e...
""" Project Euler Problem 5: https://projecteuler.net/problem=5 Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is _evenly divisible_ by all of the numbers from 1 to 20? References: - https://e...
-1
TheAlgorithms/Python
8,960
Consolidate find_min and find_min recursive and find_max and find_max_recursive
### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? * [x] Merge two different implementations into one f...
CaedenPH
2023-08-14T10:30:16Z
2023-08-14T11:17:27Z
2ab3bf2689d21e7375539c79ecee358e9d7c3359
fb1b939a89fb08370297cbb455846f61f66847bc
Consolidate find_min and find_min recursive and find_max and find_max_recursive. ### Describe your change: Merges `find_min` and `find_min_recursive` into just `find_min`. Merges `find_min` and `find_max_recursive` into just `find_max`. * [ ] Add an algorithm? * [ ] Fix a bug or typo in an existing algorithm? ...
# XGBoost Regressor Example import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def data_handling(data: dict) -> tuple: # Split dataset int...
# XGBoost Regressor Example import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def data_handling(data: dict) -> tuple: # Split dataset int...
-1