repo_name
stringclasses
1 value
pr_number
int64
4.12k
11.2k
pr_title
stringlengths
9
107
pr_description
stringlengths
107
5.48k
author
stringlengths
4
18
date_created
timestamp[ns, tz=UTC]
date_merged
timestamp[ns, tz=UTC]
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
118
5.52k
before_content
stringlengths
0
7.93M
after_content
stringlengths
0
7.93M
label
int64
-1
1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
def roman_to_int(roman: str) -> int: """ LeetCode No. 13 Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. https://en.wikipedia.org/wiki/Roman_numerals >>> tests = {"III": 3, "CLIV": 154, "MIX": 1009, "MMD": 2500, "MMMCMX...
def roman_to_int(roman: str) -> int: """ LeetCode No. 13 Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. https://en.wikipedia.org/wiki/Roman_numerals >>> tests = {"III": 3, "CLIV": 154, "MIX": 1009, "MMD": 2500, "MMMCMX...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from timeit import timeit def sum_of_digits(n: int) -> int: """ Find the sum of digits of a number. >>> sum_of_digits(12345) 15 >>> sum_of_digits(123) 6 >>> sum_of_digits(-123) 6 >>> sum_of_digits(0) 0 """ n = -n if n < 0 else n res = 0 while n > 0: res...
from timeit import timeit def sum_of_digits(n: int) -> int: """ Find the sum of digits of a number. >>> sum_of_digits(12345) 15 >>> sum_of_digits(123) 6 >>> sum_of_digits(-123) 6 >>> sum_of_digits(0) 0 """ n = -n if n < 0 else n res = 0 while n > 0: res...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" YouTube Explanation: https://www.youtube.com/watch?v=f2xi3c1S95M Given an integer n, return the minimum steps to 1 AVAILABLE STEPS: * Decrement by 1 * if n is divisible by 2, divide by 2 * if n is divisible by 3, divide by 3 Example 1: n = 10 10 -> 9 -> 3 -> 1 Result: 3 steps Example 2: n = 15 15 -...
""" YouTube Explanation: https://www.youtube.com/watch?v=f2xi3c1S95M Given an integer n, return the minimum steps to 1 AVAILABLE STEPS: * Decrement by 1 * if n is divisible by 2, divide by 2 * if n is divisible by 3, divide by 3 Example 1: n = 10 10 -> 9 -> 3 -> 1 Result: 3 steps Example 2: n = 15 15 -...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Functions useful for doing molecular chemistry: * molarity_to_normality * moles_to_pressure * moles_to_volume * pressure_and_volume_to_temperature """ def molarity_to_normality(nfactor: int, moles: float, volume: float) -> float: """ Convert molarity to normality. Volume is taken in litres. W...
""" Functions useful for doing molecular chemistry: * molarity_to_normality * moles_to_pressure * moles_to_volume * pressure_and_volume_to_temperature """ def molarity_to_normality(nfactor: int, moles: float, volume: float) -> float: """ Convert molarity to normality. Volume is taken in litres. W...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Project Euler Problem 1: https://projecteuler.net/problem=1 Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def solution(n: int = 1000) -> int: ...
""" Project Euler Problem 1: https://projecteuler.net/problem=1 Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def solution(n: int = 1000) -> int: ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Name scores Problem 22 Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a ...
""" Name scores Problem 22 Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure p...
""" Heap's (iterative) algorithm returns the list of all permutations possible from a list. It minimizes movement by generating each permutation from the previous one by swapping only two elements. More information: https://en.wikipedia.org/wiki/Heap%27s_algorithm. """ def heaps(arr: list) -> list: """ Pure p...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" One of the several implementations of Lempel–Ziv–Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch """ import math import os import sys def read_file_binary(file_path: str) -> str: """ Reads given file as bytes and returns them as a long string """ ...
""" One of the several implementations of Lempel–Ziv–Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch """ import math import os import sys def read_file_binary(file_path: str) -> str: """ Reads given file as bytes and returns them as a long string """ ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
# pack-refs with: peeled fully-peeled sorted 8668f5792dc673f085966f6f90c9c896081f22e9 refs/remotes/origin/Fewer-forward-propogations-to-speed-tests c1fd8cb9e667ab59ca4446d0dcf216d1696a010c refs/remotes/origin/Python-3.12-on-Debian-bookworm e093689124ab5f4a0938e4801abad0dbeb5bf881 refs/remotes/origin/cclauss-patch-1 04...
# pack-refs with: peeled fully-peeled sorted 8668f5792dc673f085966f6f90c9c896081f22e9 refs/remotes/origin/Fewer-forward-propogations-to-speed-tests c1fd8cb9e667ab59ca4446d0dcf216d1696a010c refs/remotes/origin/Python-3.12-on-Debian-bookworm e093689124ab5f4a0938e4801abad0dbeb5bf881 refs/remotes/origin/cclauss-patch-1 04...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
# Copyright 2016 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Picks the random index as the pivot """ import random def partition(A, left_index, right_index): pivot = A[left_index] i = left_index + 1 for j in range(left_index + 1, right_index): if A[j] < pivot: A[j], A[i] = A[i], A[j] i += 1 A[left_index], A[i - 1] = A[i - 1],...
""" Picks the random index as the pivot """ import random def partition(A, left_index, right_index): pivot = A[left_index] i = left_index + 1 for j in range(left_index + 1, right_index): if A[j] < pivot: A[j], A[i] = A[i], A[j] i += 1 A[left_index], A[i - 1] = A[i - 1],...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the ...
""" The Fibonacci sequence is defined by the recurrence relation: Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1. Hence the first 12 terms will be: F1 = 1 F2 = 1 F3 = 2 F4 = 3 F5 = 5 F6 = 8 F7 = 13 F8 = 21 F9 = 34 F10 = 55 F11 = 89 F12 = 144 The 12th term, F12, is the ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Problem 112: https://projecteuler.net/problem=112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a pos...
""" Problem 112: https://projecteuler.net/problem=112 Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a pos...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Find the kth smallest element in linear time using divide and conquer. Recall we can do this trivially in O(nlogn) time. Sort the list and access kth element in constant time. This is a divide and conquer algorithm that can find a solution in O(n) time. For more information of this algorithm: https://web.stanford...
""" Find the kth smallest element in linear time using divide and conquer. Recall we can do this trivially in O(nlogn) time. Sort the list and access kth element in constant time. This is a divide and conquer algorithm that can find a solution in O(n) time. For more information of this algorithm: https://web.stanford...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr):...
""" Author : Yvonne This is a pure Python implementation of Dynamic Programming solution to the longest_sub_array problem. The problem is : Given an array, to find the longest and continuous sub array and get the max sum of the sub array in the given array. """ class SubArray: def __init__(self, arr):...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Created on Fri Oct 16 09:31:07 2020 @author: Dr. Tobias Schröder @license: MIT-license This file contains the test-suite for the knapsack problem. """ import unittest from knapsack import knapsack as k class Test(unittest.TestCase): def test_base_case(self): """ test for the base case ...
""" Created on Fri Oct 16 09:31:07 2020 @author: Dr. Tobias Schröder @license: MIT-license This file contains the test-suite for the knapsack problem. """ import unittest from knapsack import knapsack as k class Test(unittest.TestCase): def test_base_case(self): """ test for the base case ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
def kthPermutation(k, n): """ Finds k'th lexicographic permutation (in increasing order) of 0,1,2,...n-1 in O(n^2) time. Examples: First permutation is always 0,1,2,...n >>> kthPermutation(0,5) [0, 1, 2, 3, 4] The order of permutation of 0,1,2,3 is [0,1,2,3], [0,1,3,2], [0,2,1,3], ...
def kthPermutation(k, n): """ Finds k'th lexicographic permutation (in increasing order) of 0,1,2,...n-1 in O(n^2) time. Examples: First permutation is always 0,1,2,...n >>> kthPermutation(0,5) [0, 1, 2, 3, 4] The order of permutation of 0,1,2,3 is [0,1,2,3], [0,1,3,2], [0,2,1,3], ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
from typing import Any class Node: def __init__(self, data: Any): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): temp = self.head while temp is not None: print(temp.data, end=" ") ...
from typing import Any class Node: def __init__(self, data: Any): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): temp = self.head while temp is not None: print(temp.data, end=" ") ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Project Euler Problem 2: https://projecteuler.net/problem=2 Even Fibonacci Numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequenc...
""" Project Euler Problem 2: https://projecteuler.net/problem=2 Even Fibonacci Numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequenc...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
#!/usr/bin/python # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries """ Implementing logistic regression for classification problem Helpful resources: Coursera ML course https://medium.com/@martinpella/logistic-regression-from-scratch-in-python-124c5636b8ac """ import nu...
#!/usr/bin/python # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries """ Implementing logistic regression for classification problem Helpful resources: Coursera ML course https://medium.com/@martinpella/logistic-regression-from-scratch-in-python-124c5636b8ac """ import nu...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
# Recursive Prorgam to create a Linked List from a sequence and # print a string representation of it. class Node: def __init__(self, data=None): self.data = data self.next = None def __repr__(self): """Returns a visual representation of the node and all its following nodes.""" ...
# Recursive Prorgam to create a Linked List from a sequence and # print a string representation of it. class Node: def __init__(self, data=None): self.data = data self.next = None def __repr__(self): """Returns a visual representation of the node and all its following nodes.""" ...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" Reference: https://en.wikipedia.org/wiki/Gaussian_function """ from numpy import exp, pi, sqrt def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int: """ >>> gaussian(1) 0.24197072451914337 >>> gaussian(24) 3.342714441794458e-126 >>> gaussian(1, 4, 2) 0.06475879783294587 >...
""" Reference: https://en.wikipedia.org/wiki/Gaussian_function """ from numpy import exp, pi, sqrt def gaussian(x, mu: float = 0.0, sigma: float = 1.0) -> int: """ >>> gaussian(1) 0.24197072451914337 >>> gaussian(24) 3.342714441794458e-126 >>> gaussian(1, 4, 2) 0.06475879783294587 >...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
#!/bin/sh # # Copyright (c) 2006, 2008 Junio C Hamano # # The "pre-rebase" hook is run just before "git rebase" starts doing # its job, and can prevent the command from running by exiting with # non-zero status. # # The hook is called with the following parameters: # # $1 -- the upstream the series was forked from. # $...
#!/bin/sh # # Copyright (c) 2006, 2008 Junio C Hamano # # The "pre-rebase" hook is run just before "git rebase" starts doing # its job, and can prevent the command from running by exiting with # non-zero status. # # The hook is called with the following parameters: # # $1 -- the upstream the series was forked from. # $...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
total_user,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 5...
total_user,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 5...
-1
TheAlgorithms/Python
4,224
[mypy]Correction of all errors in the sorts directory
### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [ ] Add an algorithm? * [x] Fix a bug or typo in an exi...
MatthewG25
2021-02-22T11:02:18Z
2021-02-23T09:02:31Z
02d9bc66c16a9cc851200f149fabbb07df611525
a4726ca248b3cf0470e5453ac1d9878eded38d27
[mypy]Correction of all errors in the sorts directory. ### **Describe your change:** Completion of all mypy errors apart from a stub error. See #4222 for more detail. The errors were four type annotations, and the last was a return statement error found in the cocktail_shaker_sort algorithm which was fixed. * [...
""" The algorithm finds distance between closest pair of points in the given n points. Approach used -> Divide and conquer The points are sorted based on Xco-ords and then based on Yco-ords separately. And by applying divide and conquer approach, minimum distance is obtained recursively. >> Closest points can lie on d...
""" The algorithm finds distance between closest pair of points in the given n points. Approach used -> Divide and conquer The points are sorted based on Xco-ords and then based on Yco-ords separately. And by applying divide and conquer approach, minimum distance is obtained recursively. >> Closest points can lie on d...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
import os import sys from . import rsa_key_generator as rkg DEFAULT_BLOCK_SIZE = 128 BYTE_SIZE = 256 def main(): filename = "encrypted_file.txt" response = input(r"Encrypt\Decrypt [e\d]: ") if response.lower().startswith("e"): mode = "encrypt" elif response.lower().startswith("d"): ...
import os import sys from . import rsa_key_generator as rkg DEFAULT_BLOCK_SIZE = 128 BYTE_SIZE = 256 def main(): filename = "encrypted_file.txt" response = input(r"Encrypt\Decrypt [e\d]: ") if response.lower().startswith("e"): mode = "encrypt" elif response.lower().startswith("d"): ...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
import os import random import sys from typing import Tuple from . import cryptomath_module as cryptoMath from . import rabin_miller as rabinMiller def main(): print("Making key files...") makeKeyFiles("rsa", 1024) print("Key files generation successful.") def generateKey(keySize: int) -> Tuple[Tuple[i...
import os import random import sys from typing import Tuple from . import cryptomath_module as cryptoMath from . import rabin_miller as rabinMiller def main(): print("Making key files...") makeKeyFiles("rsa", 1024) print("Key files generation successful.") def generateKey(keySize: int) -> Tuple[Tuple[i...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform The Burrows–Wheeler transform (BWT, also called block-sorting compression) rearranges a character string into runs of similar characters. This is useful for compression, since it tends to be easy to compress a string that has runs of repeated characte...
""" https://en.wikipedia.org/wiki/Burrows%E2%80%93Wheeler_transform The Burrows–Wheeler transform (BWT, also called block-sorting compression) rearranges a character string into runs of similar characters. This is useful for compression, since it tends to be easy to compress a string that has runs of repeated characte...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" A non-recursive Segment Tree implementation with range query and single element update, works virtually with any list of the same type of elements with a "commutative" combiner. Explanation: https://www.geeksforgeeks.org/iterative-segment-tree-range-minimum-query/ https://www.geeksforgeeks.org/segment-tree-efficie...
""" A non-recursive Segment Tree implementation with range query and single element update, works virtually with any list of the same type of elements with a "commutative" combiner. Explanation: https://www.geeksforgeeks.org/iterative-segment-tree-range-minimum-query/ https://www.geeksforgeeks.org/segment-tree-efficie...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" python/black : true flake8 : passed """ from typing import Iterator, Optional class RedBlackTree: """ A Red-Black tree, which is a self-balancing BST (binary search tree). This tree has similar performance to AVL trees, but the balancing is less strict, so it will perform faster for writing/de...
""" python/black : true flake8 : passed """ from typing import Iterator, Optional class RedBlackTree: """ A Red-Black tree, which is a self-balancing BST (binary search tree). This tree has similar performance to AVL trees, but the balancing is less strict, so it will perform faster for writing/de...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Implementing Deque using DoublyLinkedList ... Operations: 1. insertion in the front -> O(1) 2. insertion in the end -> O(1) 3. remove from the front -> O(1) 4. remove from the end -> O(1) """ class _DoublyLinkedBase: """ A Private class (to be inherited) """ class _Node: __slots__...
""" Implementing Deque using DoublyLinkedList ... Operations: 1. insertion in the front -> O(1) 2. insertion in the end -> O(1) 3. remove from the front -> O(1) 4. remove from the end -> O(1) """ class _DoublyLinkedBase: """ A Private class (to be inherited) """ class _Node: __slots__...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
#!/usr/bin/env python3 def climb_stairs(n: int) -> int: """ LeetCdoe No.70: Climbing Stairs Distinct ways to climb a n step staircase where each time you can either climb 1 or 2 steps. Args: n: number of steps of staircase Returns: Distinct ways to climb a n step staircase ...
#!/usr/bin/env python3 def climb_stairs(n: int) -> int: """ LeetCdoe No.70: Climbing Stairs Distinct ways to climb a n step staircase where each time you can either climb 1 or 2 steps. Args: n: number of steps of staircase Returns: Distinct ways to climb a n step staircase ...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Author : Syed Faizan (3rd Year Student IIIT Pune) github : faizan2700 You are given a bitmask m and you want to efficiently iterate through all of its submasks. The mask s is submask of m if only bits that were included in bitmask are set """ from __future__ import annotations def list_of_submasks(mask: int) -> l...
""" Author : Syed Faizan (3rd Year Student IIIT Pune) github : faizan2700 You are given a bitmask m and you want to efficiently iterate through all of its submasks. The mask s is submask of m if only bits that were included in bitmask are set """ from __future__ import annotations def list_of_submasks(mask: int) -> l...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # Load iris file iris = load_iris() iris.keys() print(f"Target names: \n {iris.target_names} ") print(f"\n Features: \n {iris.feature_names}") # Train set e Test set X_train...
from sklearn.datasets import load_iris from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier # Load iris file iris = load_iris() iris.keys() print(f"Target names: \n {iris.target_names} ") print(f"\n Features: \n {iris.feature_names}") # Train set e Test set X_train...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from __future__ import annotations def n31(a: int) -> tuple[list[int], int]: """ Returns the Collatz sequence and its length of any positive integer. >>> n31(4) ([4, 2, 1], 3) """ if not isinstance(a, int): raise TypeError("Must be int, not {}".format(type(a).__name__)) if a < 1: ...
from __future__ import annotations def n31(a: int) -> tuple[list[int], int]: """ Returns the Collatz sequence and its length of any positive integer. >>> n31(4) ([4, 2, 1], 3) """ if not isinstance(a, int): raise TypeError(f"Must be int, not {type(a).__name__}") if a < 1: ...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from __future__ import annotations from cmath import sqrt def quadratic_roots(a: int, b: int, c: int) -> tuple[complex, complex]: """ Given the numerical coefficients a, b and c, calculates the roots for any quadratic equation of the form ax^2 + bx + c >>> quadratic_roots(a=1, b=3, c=-4) (1.0, -...
from __future__ import annotations from cmath import sqrt def quadratic_roots(a: int, b: int, c: int) -> tuple[complex, complex]: """ Given the numerical coefficients a, b and c, calculates the roots for any quadratic equation of the form ax^2 + bx + c >>> quadratic_roots(a=1, b=3, c=-4) (1.0, -...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Implementation of finding nth fibonacci number using matrix exponentiation. Time Complexity is about O(log(n)*8), where 8 is the complexity of matrix multiplication of size 2 by 2. And on the other hand complexity of bruteforce solution is O(n). As we know f[n] = f[n-1] + f[n-1] Converting to matrix, [f(n),...
""" Implementation of finding nth fibonacci number using matrix exponentiation. Time Complexity is about O(log(n)*8), where 8 is the complexity of matrix multiplication of size 2 by 2. And on the other hand complexity of bruteforce solution is O(n). As we know f[n] = f[n-1] + f[n-1] Converting to matrix, [f(n),...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
class Matrix: """ <class Matrix> Matrix structure. """ def __init__(self, row: int, column: int, default_value: float = 0): """ <method Matrix.__init__> Initialize matrix with given size and default value. Example: >>> a = Matrix(2, 3, 1) >>> a ...
class Matrix: """ <class Matrix> Matrix structure. """ def __init__(self, row: int, column: int, default_value: float = 0): """ <method Matrix.__init__> Initialize matrix with given size and default value. Example: >>> a = Matrix(2, 3, 1) >>> a ...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" This is a Python implementation of the levenshtein distance. Levenshtein distance is a string metric for measuring the difference between two sequences. For doctests run following command: python -m doctest -v levenshtein-distance.py or python3 -m doctest -v levenshtein-distance.py For manual testing run: python ...
""" This is a Python implementation of the levenshtein distance. Levenshtein distance is a string metric for measuring the difference between two sequences. For doctests run following command: python -m doctest -v levenshtein-distance.py or python3 -m doctest -v levenshtein-distance.py For manual testing run: python ...
1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: L...
""" This is a pure Python implementation of the quick sort algorithm For doctests run following command: python -m doctest -v radix_sort.py or python3 -m doctest -v radix_sort.py For manual testing run: python radix_sort.py """ from __future__ import annotations from typing import List def radix_sort(list_of_ints: L...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# Python program to implement Morse Code Translator # Dictionary representing the morse code chart MORSE_CODE_DICT = { "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M...
# Python program to implement Morse Code Translator # Dictionary representing the morse code chart MORSE_CODE_DICT = { "A": ".-", "B": "-...", "C": "-.-.", "D": "-..", "E": ".", "F": "..-.", "G": "--.", "H": "....", "I": "..", "J": ".---", "K": "-.-", "L": ".-..", "M...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Kadane's algorithm to get maximum subarray sum https://medium.com/@rsinghal757/kadanes-algorithm-dynamic-programming-how-and-why-does-it-work-3fd8849ed73d https://en.wikipedia.org/wiki/Maximum_subarray_problem """ test_data: tuple = ([-2, -8, -9], [2, 8, 9], [-1, 0, 1], [0, 0], []) def negative_exist(arr: list) -...
""" Kadane's algorithm to get maximum subarray sum https://medium.com/@rsinghal757/kadanes-algorithm-dynamic-programming-how-and-why-does-it-work-3fd8849ed73d https://en.wikipedia.org/wiki/Maximum_subarray_problem """ test_data: tuple = ([-2, -8, -9], [2, 8, 9], [-1, 0, 1], [0, 0], []) def negative_exist(arr: list) -...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Numerical integration or quadrature for a smooth function f with known values at x_i This method is the classical approach of suming 'Equally Spaced Abscissas' method 1: "extended trapezoidal rule" """ def method_1(boundary, steps): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) ...
""" Numerical integration or quadrature for a smooth function f with known values at x_i This method is the classical approach of suming 'Equally Spaced Abscissas' method 1: "extended trapezoidal rule" """ def method_1(boundary, steps): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
def printDist(dist, V): print("\nVertex Distance") for i in range(V): if dist[i] != float("inf"): print(i, "\t", int(dist[i]), end="\t") else: print(i, "\t", "INF", end="\t") print() def minDist(mdist, vset, V): minVal = float("inf") minInd = -1 for ...
def printDist(dist, V): print("\nVertex Distance") for i in range(V): if dist[i] != float("inf"): print(i, "\t", int(dist[i]), end="\t") else: print(i, "\t", "INF", end="\t") print() def minDist(mdist, vset, V): minVal = float("inf") minInd = -1 for ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm def binary_or(a: int, b: int) -> str: """ Take in 2 integers, convert them to binary, and return a binary number that is the result of a binary or operation on the integers provided. >>> binary_or(25, 32) '0b111001' >>> bi...
# https://www.tutorialspoint.com/python3/bitwise_operators_example.htm def binary_or(a: int, b: int) -> str: """ Take in 2 integers, convert them to binary, and return a binary number that is the result of a binary or operation on the integers provided. >>> binary_or(25, 32) '0b111001' >>> bi...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Implementation of Bilateral filter Inputs: img: A 2d image with values in between 0 and 1 varS: variance in space dimension. varI: variance in Intensity. N: Kernel size(Must be an odd number) Output: img:A 2d zero padded image with values in between 0 and 1 """ import math import sys import cv...
""" Implementation of Bilateral filter Inputs: img: A 2d image with values in between 0 and 1 varS: variance in space dimension. varI: variance in Intensity. N: Kernel size(Must be an odd number) Output: img:A 2d zero padded image with values in between 0 and 1 """ import math import sys import cv...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Get the citation from google scholar using title and year of publication, and volume and pages of journal. """ import requests from bs4 import BeautifulSoup def get_citation(base_url: str, params: dict) -> str: """ Return the citation number. """ soup = BeautifulSoup(requests.get(base_url, params...
""" Get the citation from google scholar using title and year of publication, and volume and pages of journal. """ import requests from bs4 import BeautifulSoup def get_citation(base_url: str, params: dict) -> str: """ Return the citation number. """ soup = BeautifulSoup(requests.get(base_url, params...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# Python program for generating diamond pattern in Python 3.7+ # Function to print upper half of diamond (pyramid) def floyd(n): """ Parameters: n : size of pattern """ for i in range(0, n): for j in range(0, n - i - 1): # printing spaces print(" ", end="") for k i...
# Python program for generating diamond pattern in Python 3.7+ # Function to print upper half of diamond (pyramid) def floyd(n): """ Parameters: n : size of pattern """ for i in range(0, n): for j in range(0, n - i - 1): # printing spaces print(" ", end="") for k i...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" The function below will convert any binary string to the octal equivalent. >>> bin_to_octal("1111") '17' >>> bin_to_octal("101010101010011") '52523' >>> bin_to_octal("") Traceback (most recent call last): ... ValueError: Empty string was passed to the function >>> bin_to_octal("a-1") Traceback (most recent call ...
""" The function below will convert any binary string to the octal equivalent. >>> bin_to_octal("1111") '17' >>> bin_to_octal("101010101010011") '52523' >>> bin_to_octal("") Traceback (most recent call last): ... ValueError: Empty string was passed to the function >>> bin_to_octal("a-1") Traceback (most recent call ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Source: https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort This is a non-parallelized implementation of odd-even transpostiion sort. Normally the swaps in each set happen simultaneously, without that the algorithm is no better than bubble sort. """ def odd_even_transposition(arr: list) -> list: """ >>>...
""" Source: https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort This is a non-parallelized implementation of odd-even transpostiion sort. Normally the swaps in each set happen simultaneously, without that the algorithm is no better than bubble sort. """ def odd_even_transposition(arr: list) -> list: """ >>>...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Created on Thu Oct 5 16:44:23 2017 @author: Christian Bender This Python library contains some useful functions to deal with prime numbers and whole numbers. Overview: isPrime(number) sieveEr(N) getPrimeNumbers(N) primeFactorization(number) greatestPrimeFactor(number) smallestPrimeFactor(number) getPrime(n) ge...
""" Created on Thu Oct 5 16:44:23 2017 @author: Christian Bender This Python library contains some useful functions to deal with prime numbers and whole numbers. Overview: isPrime(number) sieveEr(N) getPrimeNumbers(N) primeFactorization(number) greatestPrimeFactor(number) smallestPrimeFactor(number) getPrime(n) ge...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple def electric_power(voltage: float, current: float, power: float) -> float: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. examples are below: ...
# https://en.m.wikipedia.org/wiki/Electric_power from collections import namedtuple def electric_power(voltage: float, current: float, power: float) -> float: """ This function can calculate any one of the three (voltage, current, power), fundamental value of electrical system. examples are below: ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" https://en.wikipedia.org/wiki/Rayleigh_quotient """ import numpy as np def is_hermitian(matrix: np.array) -> bool: """ Checks if a matrix is Hermitian. >>> import numpy as np >>> A = np.array([ ... [2, 2+1j, 4], ... [2-1j, 3, 1j], ... [4, -1j, 1]]) >>> is_hermitian(A) ...
""" https://en.wikipedia.org/wiki/Rayleigh_quotient """ import numpy as np def is_hermitian(matrix: np.array) -> bool: """ Checks if a matrix is Hermitian. >>> import numpy as np >>> A = np.array([ ... [2, 2+1j, 4], ... [2-1j, 3, 1j], ... [4, -1j, 1]]) >>> is_hermitian(A) ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Implementation of iterative merge sort in Python Author: Aman Gupta For doctests run following command: python3 -m doctest -v iterative_merge_sort.py For manual testing run: python3 iterative_merge_sort.py """ from __future__ import annotations def merge(input_list: list, low: int, mid: int, high: int) -> list...
""" Implementation of iterative merge sort in Python Author: Aman Gupta For doctests run following command: python3 -m doctest -v iterative_merge_sort.py For manual testing run: python3 iterative_merge_sort.py """ from __future__ import annotations def merge(input_list: list, low: int, mid: int, high: int) -> list...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from typing import List def merge(left_half: List, right_half: List) -> List: """Helper function for mergesort. >>> left_half = [-2] >>> right_half = [-1] >>> merge(left_half, right_half) [-2, -1] >>> left_half = [1,2,3] >>> right_half = [4,5,6] >>> merge(left_half, right_half) [...
from typing import List def merge(left_half: List, right_half: List) -> List: """Helper function for mergesort. >>> left_half = [-2] >>> right_half = [-1] >>> merge(left_half, right_half) [-2, -1] >>> left_half = [1,2,3] >>> right_half = [4,5,6] >>> merge(left_half, right_half) [...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from datetime import datetime import requests def download_video(url: str) -> bytes: base_url = "https://downloadgram.net/wp-json/wppress/video-downloader/video?url=" video_url = requests.get(base_url + url).json()[0]["urls"][0]["src"] return requests.get(video_url).content if __name__ == "__main__": ...
from datetime import datetime import requests def download_video(url: str) -> bytes: base_url = "https://downloadgram.net/wp-json/wppress/video-downloader/video?url=" video_url = requests.get(base_url + url).json()[0]["urls"][0]["src"] return requests.get(video_url).content if __name__ == "__main__": ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from .stack import Stack def balanced_parentheses(parentheses: str) -> bool: """Use a stack to check if a string of parentheses is balanced. >>> balanced_parentheses("([]{})") True >>> balanced_parentheses("[()]{}{[()()]()}") True >>> balanced_parentheses("[(])") False >>> balanced_par...
from .stack import Stack def balanced_parentheses(parentheses: str) -> bool: """Use a stack to check if a string of parentheses is balanced. >>> balanced_parentheses("([]{})") True >>> balanced_parentheses("[()]{}{[()()]()}") True >>> balanced_parentheses("[(])") False >>> balanced_par...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Project Euler Problem 38: https://projecteuler.net/problem=38 Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same c...
""" Project Euler Problem 38: https://projecteuler.net/problem=38 Take the number 192 and multiply it by each of 1, 2, and 3: 192 × 1 = 192 192 × 2 = 384 192 × 3 = 576 By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3) The same c...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" In this problem, we want to determine all possible permutations of the given sequence. We use backtracking to solve this problem. Time complexity: O(n! * n), where n denotes the length of the given sequence. """ from typing import List, Union def generate_all_permutations(sequence...
""" In this problem, we want to determine all possible permutations of the given sequence. We use backtracking to solve this problem. Time complexity: O(n! * n), where n denotes the length of the given sequence. """ from typing import List, Union def generate_all_permutations(sequence...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from __future__ import annotations def stable_matching(donor_pref: list[int], recipient_pref: list[int]) -> list[int]: """ Finds the stable match in any bipartite graph, i.e a pairing where no 2 objects prefer each other over their partner. The function accepts the preferences of oegan donors and rec...
from __future__ import annotations def stable_matching(donor_pref: list[int], recipient_pref: list[int]) -> list[int]: """ Finds the stable match in any bipartite graph, i.e a pairing where no 2 objects prefer each other over their partner. The function accepts the preferences of oegan donors and rec...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Author : Mehdi ALAOUI This is a pure Python implementation of Dynamic Programming solution to the longest increasing subsequence of a given sequence. The problem is : Given an array, to find the longest and increasing sub-array in that given array and return it. Example: [10, 22, 9, 33, 21, 50, 41, 60, 80] as i...
""" Author : Mehdi ALAOUI This is a pure Python implementation of Dynamic Programming solution to the longest increasing subsequence of a given sequence. The problem is : Given an array, to find the longest and increasing sub-array in that given array and return it. Example: [10, 22, 9, 33, 21, 50, 41, 60, 80] as i...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Code contributed by Honey Sharma Source: https://en.wikipedia.org/wiki/Cycle_sort """ def cycle_sort(array: list) -> list: """ >>> cycle_sort([4, 3, 2, 1]) [1, 2, 3, 4] >>> cycle_sort([-4, 20, 0, -50, 100, -1]) [-50, -4, -1, 0, 20, 100] >>> cycle_sort([-.1, -.2, 1.3, -.8]) [-0.8, -0....
""" Code contributed by Honey Sharma Source: https://en.wikipedia.org/wiki/Cycle_sort """ def cycle_sort(array: list) -> list: """ >>> cycle_sort([4, 3, 2, 1]) [1, 2, 3, 4] >>> cycle_sort([-4, 20, 0, -50, 100, -1]) [-50, -4, -1, 0, 20, 100] >>> cycle_sort([-.1, -.2, 1.3, -.8]) [-0.8, -0....
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Find Volumes of Various Shapes. Wikipedia reference: https://en.wikipedia.org/wiki/Volume """ from math import pi, pow from typing import Union def vol_cube(side_length: Union[int, float]) -> float: """ Calculate the Volume of a Cube. >>> vol_cube(1) 1.0 >>> vol_cube(3) 27.0 """ ...
""" Find Volumes of Various Shapes. Wikipedia reference: https://en.wikipedia.org/wiki/Volume """ from math import pi, pow from typing import Union def vol_cube(side_length: Union[int, float]) -> float: """ Calculate the Volume of a Cube. >>> vol_cube(1) 1.0 >>> vol_cube(3) 27.0 """ ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" A pure Python implementation of the insertion sort algorithm This algorithm sorts a collection by comparing adjacent elements. When it finds that order is not respected, it moves the element compared backward until the order is correct. It then goes back directly to the element's initial position resuming forward...
""" A pure Python implementation of the insertion sort algorithm This algorithm sorts a collection by comparing adjacent elements. When it finds that order is not respected, it moves the element compared backward until the order is correct. It then goes back directly to the element's initial position resuming forward...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Problem 44: https://projecteuler.net/problem=44 Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are: 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 − 22 = 48, is not pentagonal. Find the pai...
""" Problem 44: https://projecteuler.net/problem=44 Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are: 1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference, 70 − 22 = 48, is not pentagonal. Find the pai...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
from typing import Iterable, List, Optional class Heap: """A Max Heap Implementation >>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5] >>> h = Heap() >>> h.build_max_heap(unsorted) >>> print(h) [209, 201, 25, 103, 107, 15, 1, 9, 7, 11, 5] >>> >>> h.extract_max() 209 ...
from typing import Iterable, List, Optional class Heap: """A Max Heap Implementation >>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5] >>> h = Heap() >>> h.build_max_heap(unsorted) >>> print(h) [209, 201, 25, 103, 107, 15, 1, 9, 7, 11, 5] >>> >>> h.extract_max() 209 ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
""" Project Euler Problem 8: https://projecteuler.net/problem=8 Largest product in a series The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 8586...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Recaptcha is a free captcha service offered by Google in order to secure websites and forms. At https://www.google.com/recaptcha/admin/create you can create new recaptcha keys and see the keys that your have already created. * Keep in mind that recaptcha doesn't work with localhost When you create a recaptcha key,...
""" Recaptcha is a free captcha service offered by Google in order to secure websites and forms. At https://www.google.com/recaptcha/admin/create you can create new recaptcha keys and see the keys that your have already created. * Keep in mind that recaptcha doesn't work with localhost When you create a recaptcha key,...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Find the area of various geometric shapes """ from math import pi, sqrt def surface_area_cube(side_length: float) -> float: """ Calculate the Surface Area of a Cube. >>> surface_area_cube(1) 6 >>> surface_area_cube(3) 54 >>> surface_area_cube(-1) Traceback (most recent call last):...
""" Find the area of various geometric shapes """ from math import pi, sqrt def surface_area_cube(side_length: float) -> float: """ Calculate the Surface Area of a Cube. >>> surface_area_cube(1) 6 >>> surface_area_cube(3) 54 >>> surface_area_cube(-1) Traceback (most recent call last):...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" One of the several implementations of Lempel–Ziv–Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch """ import math import os import sys def read_file_binary(file_path: str) -> str: """ Reads given file as bytes and returns them as a long string """ ...
""" One of the several implementations of Lempel–Ziv–Welch compression algorithm https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch """ import math import os import sys def read_file_binary(file_path: str) -> str: """ Reads given file as bytes and returns them as a long string """ ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock's price for all n days. The span Si of the stock's price on a given day i is defined as the maximum number of consecutive days just before the given day, for which the pri...
""" The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock's price for all n days. The span Si of the stock's price on a given day i is defined as the maximum number of consecutive days just before the given day, for which the pri...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" An RSA prime factor algorithm. The program can efficiently factor RSA prime number given the private key d and public key e. Source: on page 3 of https://crypto.stanford.edu/~dabo/papers/RSA-survey.pdf More readable source: https://www.di-mgt.com.au/rsa_factorize_n.html large number can take minutes to factor, the...
""" An RSA prime factor algorithm. The program can efficiently factor RSA prime number given the private key d and public key e. Source: on page 3 of https://crypto.stanford.edu/~dabo/papers/RSA-survey.pdf More readable source: https://www.di-mgt.com.au/rsa_factorize_n.html large number can take minutes to factor, the...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Problem 39: https://projecteuler.net/problem=39 If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. {20,48,52}, {24,45,51}, {30,40,50} For which value of p ≤ 1000, is the number of solutions maximised? """ from __future__ import anno...
""" Problem 39: https://projecteuler.net/problem=39 If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120. {20,48,52}, {24,45,51}, {30,40,50} For which value of p ≤ 1000, is the number of solutions maximised? """ from __future__ import anno...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# Min heap data structure # with decrease key functionality - in O(log(n)) time class Node: def __init__(self, name, val): self.name = name self.val = val def __str__(self): return f"{self.__class__.__name__}({self.name}, {self.val})" def __lt__(self, other): return self....
# Min heap data structure # with decrease key functionality - in O(log(n)) time class Node: def __init__(self, name, val): self.name = name self.val = val def __str__(self): return f"{self.__class__.__name__}({self.name}, {self.val})" def __lt__(self, other): return self....
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" A binary search Tree """ class Node: def __init__(self, value, parent): self.value = value self.parent = parent # Added in order to delete a node easier self.left = None self.right = None def __repr__(self): from pprint import pformat if self.left is None...
""" A binary search Tree """ class Node: def __init__(self, value, parent): self.value = value self.parent = parent # Added in order to delete a node easier self.left = None self.right = None def __repr__(self): from pprint import pformat if self.left is None...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Bead sort only works for sequences of nonegative integers. https://en.wikipedia.org/wiki/Bead_sort """ def bead_sort(sequence: list) -> list: """ >>> bead_sort([6, 11, 12, 4, 1, 5]) [1, 4, 5, 6, 11, 12] >>> bead_sort([9, 8, 7, 6, 5, 4 ,3, 2, 1]) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> bead_sort(...
""" Bead sort only works for sequences of nonegative integers. https://en.wikipedia.org/wiki/Bead_sort """ def bead_sort(sequence: list) -> list: """ >>> bead_sort([6, 11, 12, 4, 1, 5]) [1, 4, 5, 6, 11, 12] >>> bead_sort([9, 8, 7, 6, 5, 4 ,3, 2, 1]) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> bead_sort(...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# https://en.wikipedia.org/wiki/B%C3%A9zier_curve # https://www.tutorialspoint.com/computer_graphics/computer_graphics_curves.htm from __future__ import annotations from scipy.special import comb class BezierCurve: """ Bezier curve is a weighted sum of a set of control points. Generate Bezier curves from...
# https://en.wikipedia.org/wiki/B%C3%A9zier_curve # https://www.tutorialspoint.com/computer_graphics/computer_graphics_curves.htm from __future__ import annotations from scipy.special import comb class BezierCurve: """ Bezier curve is a weighted sum of a set of control points. Generate Bezier curves from...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Implementation of a basic regression decision tree. Input data set: The input data set must be 1-dimensional with continuous labels. Output: The decision tree maps a real number input to a real number output. """ import numpy as np class Decision_Tree: def __init__(self, depth=5, min_leaf_size=5): sel...
""" Implementation of a basic regression decision tree. Input data set: The input data set must be 1-dimensional with continuous labels. Output: The decision tree maps a real number input to a real number output. """ import numpy as np class Decision_Tree: def __init__(self, depth=5, min_leaf_size=5): sel...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Project Euler Problem 57: https://projecteuler.net/problem=57 It is possible to show that the square root of two can be expressed as an infinite continued fraction. sqrt(2) = 1 + 1 / (2 + 1 / (2 + 1 / (2 + ...))) By expanding this for the first four iterations, we get: 1 + 1 / 2 = 3 / 2 = 1.5 1 + 1 / (2 + 1 / 2} ...
""" Project Euler Problem 57: https://projecteuler.net/problem=57 It is possible to show that the square root of two can be expressed as an infinite continued fraction. sqrt(2) = 1 + 1 / (2 + 1 / (2 + 1 / (2 + ...))) By expanding this for the first four iterations, we get: 1 + 1 / 2 = 3 / 2 = 1.5 1 + 1 / (2 + 1 / 2} ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
class Graph: def __init__(self, vertex): self.vertex = vertex self.graph = [[0] * vertex for i in range(vertex)] def add_edge(self, u, v): self.graph[u - 1][v - 1] = 1 self.graph[v - 1][u - 1] = 1 def show(self): for i in self.graph: for j in i: ...
class Graph: def __init__(self, vertex): self.vertex = vertex self.graph = [[0] * vertex for i in range(vertex)] def add_edge(self, u, v): self.graph[u - 1][v - 1] = 1 self.graph[v - 1][u - 1] = 1 def show(self): for i in self.graph: for j in i: ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
# https://en.wikipedia.org/wiki/Hill_climbing import math class SearchProblem: """ An interface to define search problems. The interface will be illustrated using the example of mathematical function. """ def __init__(self, x: int, y: int, step_size: int, function_to_optimize): """ ...
# https://en.wikipedia.org/wiki/Hill_climbing import math class SearchProblem: """ An interface to define search problems. The interface will be illustrated using the example of mathematical function. """ def __init__(self, x: int, y: int, step_size: int, function_to_optimize): """ ...
-1
TheAlgorithms/Python
4,118
Changes occurences of str.format to f-strings
### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md). * [x] This pull request is all my own...
CarsonHam
2021-01-13T04:57:54Z
2021-02-23T05:53:49Z
f680806894d39265f810e7257d50aa0beaf2152e
61f3119467584de53a2f4395e3c03a8e12d67d30
Changes occurences of str.format to f-strings. ### **Describe your change:** fixes: #4117 * [ ] Add an algorithm? * [x] Fix a bug or typo in an existing algorithm? * [ ] Documentation change? ### **Checklist:** * [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUT...
""" Project Euler Problem 206: https://projecteuler.net/problem=206 Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0, where each “_” is a single digit. ----- Instead of computing every single permutation of that number and going through a 10^9 search space, we can narrow it down conside...
""" Project Euler Problem 206: https://projecteuler.net/problem=206 Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0, where each “_” is a single digit. ----- Instead of computing every single permutation of that number and going through a 10^9 search space, we can narrow it down conside...
-1