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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Conway's Game of Life implemented in Python.
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
"""
from __future__ import annotations
from typing import List
from PIL import Image
# Define glider example
GLIDER = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
... | """
Conway's Game of Life implemented in Python.
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
"""
from __future__ import annotations
from typing import List
from PIL import Image
# Define glider example
GLIDER = [
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0, 0],
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/python
"""Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
Simple example of Fractal generation using recursive function.
What is Sierpinski Triangle?
>>The Sierpinski triangle (also with the original orthography Sierpinski), also called
the Sierpinski gasket or the Sierpinski Sieve, ... | #!/usr/bin/python
"""Author Anurag Kumar | anuragkumarak95@gmail.com | git/anuragkumarak95
Simple example of Fractal generation using recursive function.
What is Sierpinski Triangle?
>>The Sierpinski triangle (also with the original orthography Sierpinski), also called
the Sierpinski gasket or the Sierpinski Sieve, ... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | def bubble_sort(list_data: list, length: int = 0) -> list:
"""
It is similar is bubble sort but recursive.
:param list_data: mutable ordered sequence of elements
:param length: length of list data
:return: the same list in ascending order
>>> bubble_sort([0, 5, 2, 3, 2], 5)
[0, 2, 2, 3, 5]
... | def bubble_sort(list_data: list, length: int = 0) -> list:
"""
It is similar is bubble sort but recursive.
:param list_data: mutable ordered sequence of elements
:param length: length of list data
:return: the same list in ascending order
>>> bubble_sort([0, 5, 2, 3, 2], 5)
[0, 2, 2, 3, 5]
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Given weights and values of n items, put these items in a knapsack of
capacity W to get the maximum total value in the knapsack.
Note that only the integer weights 0-1 knapsack problem is solvable
using dynamic programming.
"""
def MF_knapsack(i, wt, val, j):
"""
This code involves the concept of memor... | """
Given weights and values of n items, put these items in a knapsack of
capacity W to get the maximum total value in the knapsack.
Note that only the integer weights 0-1 knapsack problem is solvable
using dynamic programming.
"""
def MF_knapsack(i, wt, val, j):
"""
This code involves the concept of memor... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
This is a Python implementation for questions involving task assignments between people.
Here Bitmasking and DP are used for solving this.
Question :-
We have N tasks and M people. Each person in M can do only certain of these tasks. Also
a person can do only one task and a task is performed only by one person.
F... | """
This is a Python implementation for questions involving task assignments between people.
Here Bitmasking and DP are used for solving this.
Question :-
We have N tasks and M people. Each person in M can do only certain of these tasks. Also
a person can do only one task and a task is performed only by one person.
F... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | import pandas as pd
from matplotlib import pyplot as plt
from sklearn.linear_model import LinearRegression
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
# Fitting Polynomial Regression to the dataset
from sklearn.preprocessing import PolynomialFeatures... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Problem 28
Url: https://projecteuler.net/problem=28
Statement:
Starting with the number 1 and moving to the right in a clockwise direction a 5
by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the num... | """
Problem 28
Url: https://projecteuler.net/problem=28
Statement:
Starting with the number 1 and moving to the right in a clockwise direction a 5
by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the num... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/env python3
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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm
def binary_xor(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary,
return a binary number that is the
result of a binary xor operation on the integers provided.
>>> binary_xor(25, 32)
'0b111001'
>>>... | # https://www.tutorialspoint.com/python3/bitwise_operators_example.htm
def binary_xor(a: int, b: int) -> str:
"""
Take in 2 integers, convert them to binary,
return a binary number that is the
result of a binary xor operation on the integers provided.
>>> binary_xor(25, 32)
'0b111001'
>>>... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | import base64
def encode_to_b16(inp: str) -> bytes:
"""
Encodes a given utf-8 string into base-16.
>>> encode_to_b16('Hello World!')
b'48656C6C6F20576F726C6421'
>>> encode_to_b16('HELLO WORLD!')
b'48454C4C4F20574F524C4421'
>>> encode_to_b16('')
b''
"""
encoded = inp.encode("utf... | import base64
def encode_to_b16(inp: str) -> bytes:
"""
Encodes a given utf-8 string into base-16.
>>> encode_to_b16('Hello World!')
b'48656C6C6F20576F726C6421'
>>> encode_to_b16('HELLO WORLD!')
b'48454C4C4F20574F524C4421'
>>> encode_to_b16('')
b''
"""
encoded = inp.encode("utf... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Author : 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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | import math
from timeit import timeit
def num_digits(n: int) -> int:
"""
Find the number of digits in a number.
>>> num_digits(12345)
5
>>> num_digits(123)
3
>>> num_digits(0)
1
>>> num_digits(-1)
1
>>> num_digits(-123456)
6
"""
digits = 0
n = abs(n)
wh... | import math
from timeit import timeit
def num_digits(n: int) -> int:
"""
Find the number of digits in a number.
>>> num_digits(12345)
5
>>> num_digits(123)
3
>>> num_digits(0)
1
>>> num_digits(-1)
1
>>> num_digits(-123456)
6
"""
digits = 0
n = abs(n)
wh... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Project Euler Problem 207: https://projecteuler.net/problem=207
Problem Statement:
For some positive integers k, there exists an integer partition of the form
4**t = 2**t + k, where 4**t, 2**t, and k are all positive integers and t is a real
number. The first two such partitions are 4**1 = 2**1 + 2 and
4**1.58496... | """
Project Euler Problem 207: https://projecteuler.net/problem=207
Problem Statement:
For some positive integers k, there exists an integer partition of the form
4**t = 2**t + k, where 4**t, 2**t, and k are all positive integers and t is a real
number. The first two such partitions are 4**1 = 2**1 + 2 and
4**1.58496... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Algorithm that merges two sorted linked lists into one sorted linked list.
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from typing import Optional
test_data_odd = (3, 9, -11, 0, 7, 5, 1, -1)
test_data_even = (4, 6, 2, 0, 8, 10, 3, -2)
@... | """
Algorithm that merges two sorted linked lists into one sorted linked list.
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from typing import Optional
test_data_odd = (3, 9, -11, 0, 7, 5, 1, -1)
test_data_even = (4, 6, 2, 0, 8, 10, 3, -2)
@... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/env python3
"""
Illustrate how to implement bucket sort algorithm.
Author: OMKAR PATHAK
This program will illustrate how to implement bucket sort algorithm
Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works
by distributing the elements of an array into a number of buckets.
Each buc... | #!/usr/bin/env python3
"""
Illustrate how to implement bucket sort algorithm.
Author: OMKAR PATHAK
This program will illustrate how to implement bucket sort algorithm
Wikipedia says: Bucket sort, or bin sort, is a sorting algorithm that works
by distributing the elements of an array into a number of buckets.
Each buc... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | 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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Name 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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | from math import asin, atan, cos, radians, sin, sqrt, tan
def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
"""
Calculate great circle distance between two points in a sphere,
given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula
We know tha... | from math import asin, atan, cos, radians, sin, sqrt, tan
def haversine_distance(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
"""
Calculate great circle distance between two points in a sphere,
given longitudes and latitudes https://en.wikipedia.org/wiki/Haversine_formula
We know tha... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | PNG
IHDR = iCCPICC Profile (UoT?o\?US[IB*unS6mUoxBISA$=t@hpS]Ƹ9w>5@WI`]5;V! A'@{N\..ƅG_!7suV$BlW=}i; F)A<.&Xax,38S(b*%31l#O-zQvaXOP5o6Zz&⻏^wkI/#&\%x/@{7S މjPh͔&mry>k7=ߪB#@fs_{덱п0-LZ~%Gpˈ{YXf^+_s-T>D@קƸ-9!r[2]3BcnCs?>*ԮeD|%4`:X2pQSLPRaeyqĘ
י... | PNG
IHDR = iCCPICC Profile (UoT?o\?US[IB*unS6mUoxBISA$=t@hpS]Ƹ9w>5@WI`]5;V! A'@{N\..ƅG_!7suV$BlW=}i; F)A<.&Xax,38S(b*%31l#O-zQvaXOP5o6Zz&⻏^wkI/#&\%x/@{7S މjPh͔&mry>k7=ߪB#@fs_{덱п0-LZ~%Gpˈ{YXf^+_s-T>D@קƸ-9!r[2]3BcnCs?>*ԮeD|%4`:X2pQSLPRaeyqĘ
י... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # Fibonacci Sequence Using Recursion
def recur_fibo(n: int) -> int:
"""
>>> [recur_fibo(i) for i in range(12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
"""
return n if n <= 1 else recur_fibo(n - 1) + recur_fibo(n - 2)
def main() -> None:
limit = int(input("How many terms to include in fibon... | # Fibonacci Sequence Using Recursion
def recur_fibo(n: int) -> int:
"""
>>> [recur_fibo(i) for i in range(12)]
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
"""
return n if n <= 1 else recur_fibo(n - 1) + recur_fibo(n - 2)
def main() -> None:
limit = int(input("How many terms to include in fibon... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
Project Euler Problem 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,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | import argparse
import datetime
def zeller(date_input: str) -> str:
"""
Zellers Congruence Algorithm
Find the day of the week for nearly any Gregorian or Julian calendar date
>>> zeller('01-31-2010')
'Your date 01-31-2010, is a Sunday!'
Validate out of range month
>>> zeller('13-31-2010... | import argparse
import datetime
def zeller(date_input: str) -> str:
"""
Zellers Congruence Algorithm
Find the day of the week for nearly any Gregorian or Julian calendar date
>>> zeller('01-31-2010')
'Your date 01-31-2010, is a Sunday!'
Validate out of range month
>>> zeller('13-31-2010... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | from typing import Tuple
def modular_division(a: int, b: int, n: int) -> int:
"""
Modular Division :
An efficient algorithm for dividing b by a modulo n.
GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm... | from typing import Tuple
def modular_division(a: int, b: int, n: int) -> int:
"""
Modular Division :
An efficient algorithm for dividing b by a modulo n.
GCD ( Greatest Common Divisor ) or HCF ( Highest Common Factor )
Given three integers a, b, and n, such that gcd(a,n)=1 and n>1, the algorithm... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | #!/usr/bin/python
"""
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a
finite sequence.
For more details visit
wikipedia/Fischer-Yates-Shuffle.
"""
import random
def FYshuffle(list):
for i in range(len(list)):
a = random.randint(0, len(list) - 1)
b = random.randint... | #!/usr/bin/python
"""
The Fisher–Yates shuffle is an algorithm for generating a random permutation of a
finite sequence.
For more details visit
wikipedia/Fischer-Yates-Shuffle.
"""
import random
def FYshuffle(list):
for i in range(len(list)):
a = random.randint(0, len(list) - 1)
b = random.randint... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """
A Hamiltonian cycle (Hamiltonian circuit) is a graph cycle
through a graph that visits each node exactly once.
Determining whether such paths and cycles exist in graphs
is the 'Hamiltonian path problem', which is NP-complete.
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
"""
from ty... | """
A Hamiltonian cycle (Hamiltonian circuit) is a graph cycle
through a graph that visits each node exactly once.
Determining whether such paths and cycles exist in graphs
is the 'Hamiltonian path problem', which is NP-complete.
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
"""
from ty... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | from graphs.minimum_spanning_tree_kruskal import kruskal
def test_kruskal_successful_result():
num_nodes, num_edges = 9, 14
edges = [
[0, 1, 4],
[0, 7, 8],
[1, 2, 8],
[7, 8, 7],
[7, 6, 1],
[2, 8, 2],
[8, 6, 6],
[2, 3, 7],
[2, 5, 4],
... | from graphs.minimum_spanning_tree_kruskal import kruskal
def test_kruskal_successful_result():
num_nodes, num_edges = 9, 14
edges = [
[0, 1, 4],
[0, 7, 8],
[1, 2, 8],
[7, 8, 7],
[7, 6, 1],
[2, 8, 2],
[8, 6, 6],
[2, 3, 7],
[2, 5, 4],
... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | def oct_to_decimal(oct_string: str) -> int:
"""
Convert a octal value to its decimal equivalent
>>> oct_to_decimal("12")
10
>>> oct_to_decimal(" 12 ")
10
>>> oct_to_decimal("-45")
-37
>>> oct_to_decimal("2-0Fm")
Traceback (most recent call last):
...
ValueError: Non-oc... | def oct_to_decimal(oct_string: str) -> int:
"""
Convert a octal value to its decimal equivalent
>>> oct_to_decimal("12")
10
>>> oct_to_decimal(" 12 ")
10
>>> oct_to_decimal("-45")
-37
>>> oct_to_decimal("2-0Fm")
Traceback (most recent call last):
...
ValueError: Non-oc... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | -1 | ||
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | """Absolute Value."""
def abs_val(num):
"""
Find the absolute value of a number.
>>> abs_val(-5.1)
5.1
>>> abs_val(-5) == abs_val(5)
True
>>> abs_val(0)
0
"""
return -num if num < 0 else num
def test_abs_val():
"""
>>> test_abs_val()
"""
assert 0 == abs_val(0... | """Absolute Value."""
def abs_val(num):
"""
Find the absolute value of a number.
>>> abs_val(-5.1)
5.1
>>> abs_val(-5) == abs_val(5)
True
>>> abs_val(0)
0
"""
return -num if num < 0 else num
def test_abs_val():
"""
>>> test_abs_val()
"""
assert 0 == abs_val(0... | -1 |
TheAlgorithms/Python | 4,293 | [mypy] fix small folders 2 | ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
* [x] This pull request is al... | algobytewise | 2021-03-26T10:13:28Z | 2021-03-26T11:21:17Z | 959507901ac8f10cd605c51c305d13b27d105536 | 9b60be67afca18f0d5e50e532096a68605d61b81 | [mypy] fix small folders 2. ### **Describe your change:**
Related Issue: #4052
* [ ] Add an algorithm?
* [x] Fix a bug or typo in an existing algorithm?
* [ ] Documentation change?
### **Checklist:**
* [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
*... | # git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
| # git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
| -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | name: "build"
on:
pull_request:
schedule:
- cron: "0 0 * * *" # Run everyday
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
with:
path: ~... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... |
## Arithmetic Analysis
* [Bisection](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/bisection.py)
* [Gaussian Elimination](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/gaussian_elimination.py)
* [In Static Equilibrium](https://github.com/TheAlgorithms/Python/bl... |
## Arithmetic Analysis
* [Bisection](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/bisection.py)
* [Gaussian Elimination](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/gaussian_elimination.py)
* [In Static Equilibrium](https://github.com/TheAlgorithms/Python/bl... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | from typing import List
def max_difference(a: List[int]) -> (int, int):
"""
We are given an array A[1..n] of integers, n >= 1. We want to
find a pair of indices (i, j) such that
1 <= i <= j <= n and A[j] - A[i] is as large as possible.
Explanation:
https://www.geeksforgeeks.org/maximum-differ... | def max_difference(a: list[int]) -> tuple[int, int]:
"""
We are given an array A[1..n] of integers, n >= 1. We want to
find a pair of indices (i, j) such that
1 <= i <= j <= n and A[j] - A[i] is as large as possible.
Explanation:
https://www.geeksforgeeks.org/maximum-difference-between-two-elem... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | from __future__ import annotations
import math
def default_matrix_multiplication(a: list, b: list) -> list:
"""
Multiplication only for 2x2 matrices
"""
if len(a) != 2 or len(a[0]) != 2 or len(b) != 2 or len(b[0]) != 2:
raise Exception("Matrices are not 2x2")
new_matrix = [
[a[0][... | from __future__ import annotations
import math
def default_matrix_multiplication(a: list, b: list) -> list:
"""
Multiplication only for 2x2 matrices
"""
if len(a) != 2 or len(a[0]) != 2 or len(b) != 2 or len(b[0]) != 2:
raise Exception("Matrices are not 2x2")
new_matrix = [
[a[0][... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # https://en.m.wikipedia.org/wiki/Electric_power
from collections import namedtuple
from typing import Tuple
def electric_power(voltage: float, current: float, power: float) -> Tuple:
"""
This function can calculate any one of the three (voltage, current, power),
fundamental value of electrical system.
... | # https://en.m.wikipedia.org/wiki/Electric_power
from collections import namedtuple
from typing import Tuple
def electric_power(voltage: float, current: float, power: float) -> Tuple:
"""
This function can calculate any one of the three (voltage, current, power),
fundamental value of electrical system.
... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # https://en.wikipedia.org/wiki/Ohm%27s_law
from typing import Dict
def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, float]:
"""
Apply Ohm's Law, on any two given electrical values, which can be voltage, current,
and resistance, and then in a Python dict return name/value pair ... | # https://en.wikipedia.org/wiki/Ohm%27s_law
from typing import Dict
def ohms_law(voltage: float, current: float, resistance: float) -> Dict[str, float]:
"""
Apply Ohm's Law, on any two given electrical values, which can be voltage, current,
and resistance, and then in a Python dict return name/value pair ... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | if __name__ == "__main__":
import socket # Import socket module
sock = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12312
sock.connect((host, port))
sock.send(b"Hello server!")
with open("Received_file", "wb") as out_file:
... | if __name__ == "__main__":
import socket # Import socket module
sock = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12312
sock.connect((host, port))
sock.send(b"Hello server!")
with open("Received_file", "wb") as out_file:
... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
import socket
port = 12312 # Reserve a port for your service.
sock = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
sock.bind((host, port)) # Bind to the port
sock.list... | def send_file(filename: str = "mytext.txt", testing: bool = False) -> None:
import socket
port = 12312 # Reserve a port for your service.
sock = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
sock.bind((host, port)) # Bind to the port
sock.list... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # https://github.com/rupansh/QuantumComputing/blob/master/rippleadd.py
# https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
# https://en.wikipedia.org/wiki/Controlled_NOT_gate
from qiskit import Aer, QuantumCircuit, execute
from qiskit.providers import BaseBackend
def store_two_classics(val1: int, val2: in... | # https://github.com/rupansh/QuantumComputing/blob/master/rippleadd.py
# https://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
# https://en.wikipedia.org/wiki/Controlled_NOT_gate
from qiskit import Aer, QuantumCircuit, execute
from qiskit.providers import BaseBackend
def store_two_classics(val1: int, val2: in... | 1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Ordered fractions
Problem 71
https://projecteuler.net/problem=71
Consider the fraction n/d, where n and d are positive
integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8
in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, ... | """
Ordered fractions
Problem 71
https://projecteuler.net/problem=71
Consider the fraction n/d, where n and d are positive
integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8
in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """Find mean of a list of numbers."""
def average(nums):
"""Find mean of a list of numbers."""
return sum(nums) / len(nums)
def test_average():
"""
>>> test_average()
"""
assert 12.0 == average([3, 6, 9, 12, 15, 18, 21])
assert 20 == average([5, 10, 15, 20, 25, 30, 35])
assert 4.5 ==... | """Find mean of a list of numbers."""
def average(nums):
"""Find mean of a list of numbers."""
return sum(nums) / len(nums)
def test_average():
"""
>>> test_average()
"""
assert 12.0 == average([3, 6, 9, 12, 15, 18, 21])
assert 20 == average([5, 10, 15, 20, 25, 30, 35])
assert 4.5 ==... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """Matrix Exponentiation"""
import timeit
"""
Matrix Exponentiation is a technique to solve linear recurrences in logarithmic time.
You read more about it here:
http://zobayer.blogspot.com/2010/11/matrix-exponentiation.html
https://www.hackerearth.com/practice/notes/matrix-exponentiation-1/
"""
class Matrix:
de... | """Matrix Exponentiation"""
import timeit
"""
Matrix Exponentiation is a technique to solve linear recurrences in logarithmic time.
You read more about it here:
http://zobayer.blogspot.com/2010/11/matrix-exponentiation.html
https://www.hackerearth.com/practice/notes/matrix-exponentiation-1/
"""
class Matrix:
de... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Greatest Common Divisor.
Wikipedia reference: https://en.wikipedia.org/wiki/Greatest_common_divisor
gcd(a, b) = gcd(a, -b) = gcd(-a, b) = gcd(-a, -b) by definition of divisibility
"""
def greatest_common_divisor(a: int, b: int) -> int:
"""
Calculate Greatest Common Divisor (GCD).
>>> greatest_common... | """
Greatest Common Divisor.
Wikipedia reference: https://en.wikipedia.org/wiki/Greatest_common_divisor
gcd(a, b) = gcd(a, -b) = gcd(-a, b) = gcd(-a, -b) by definition of divisibility
"""
def greatest_common_divisor(a: int, b: int) -> int:
"""
Calculate Greatest Common Divisor (GCD).
>>> greatest_common... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Implementation of median filter algorithm
"""
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, int8, multiply, ravel, sort, zeros_like
def median_filter(gray_img, mask=3):
"""
:param gray_img: gray image
:param mask: mask size
:return: image with median f... | """
Implementation of median filter algorithm
"""
from cv2 import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey
from numpy import divide, int8, multiply, ravel, sort, zeros_like
def median_filter(gray_img, mask=3):
"""
:param gray_img: gray image
:param mask: mask size
:return: image with median f... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def solution(num: int = 100) -> int:
... | """
Problem 20: https://projecteuler.net/problem=20
n! means n × (n − 1) × ... × 3 × 2 × 1
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!
"""
def solution(num: int = 100) -> int:
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | from __future__ import annotations
from collections import Counter
from random import random
class MarkovChainGraphUndirectedUnweighted:
"""
Undirected Unweighted Graph for running Markov Chain Algorithm
"""
def __init__(self):
self.connections = {}
def add_node(self, node: str) -> None... | from __future__ import annotations
from collections import Counter
from random import random
class MarkovChainGraphUndirectedUnweighted:
"""
Undirected Unweighted Graph for running Markov Chain Algorithm
"""
def __init__(self):
self.connections = {}
def add_node(self, node: str) -> None... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | #!/usr/bin/env python3
"""
Build a quantum circuit with pair or group of qubits to perform
quantum entanglement.
Quantum entanglement is a phenomenon observed at the quantum scale
where entangled particles stay connected (in some sense) so that
the actions performed on one of the particles affects the other,
no matter ... | #!/usr/bin/env python3
"""
Build a quantum circuit with pair or group of qubits to perform
quantum entanglement.
Quantum entanglement is a phenomenon observed at the quantum scale
where entangled particles stay connected (in some sense) so that
the actions performed on one of the particles affects the other,
no matter ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | import json
import requests
from .fetch_github_info import AUTHENTICATED_USER_ENDPOINT, fetch_github_info
def test_fetch_github_info(monkeypatch):
class FakeResponse:
def __init__(self, content) -> None:
assert isinstance(content, (bytes, str))
self.content = content
def... | import json
import requests
from .fetch_github_info import AUTHENTICATED_USER_ENDPOINT, fetch_github_info
def test_fetch_github_info(monkeypatch):
class FakeResponse:
def __init__(self, content) -> None:
assert isinstance(content, (bytes, str))
self.content = content
def... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Approximates the area under the curve using the trapezoidal rule
"""
from typing import Callable, Union
def trapezoidal_area(
fnc: Callable[[Union[int, float]], Union[int, float]],
x_start: Union[int, float],
x_end: Union[int, float],
steps: int = 100,
) -> float:
"""
Treats curve as a co... | """
Approximates the area under the curve using the trapezoidal rule
"""
from typing import Callable, Union
def trapezoidal_area(
fnc: Callable[[Union[int, float]], Union[int, float]],
x_start: Union[int, float],
x_end: Union[int, float],
steps: int = 100,
) -> float:
"""
Treats curve as a co... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Project Euler Problem 7: https://projecteuler.net/problem=7
10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we
can see that the 6th prime is 13.
What is the 10001st prime number?
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
from math import sqrt
def is_prime(... | """
Project Euler Problem 7: https://projecteuler.net/problem=7
10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we
can see that the 6th prime is 13.
What is the 10001st prime number?
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
from math import sqrt
def is_prime(... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
- - - - - -- - - - - - - - - - - - - - - - - - - - - - -
Name - - CNN - Convolution Neural Network For Photo Recognizing
Goal - - Recognize Handing Writing Word Photo
Detail:Total 5 layers neural network
* Convolution layer
* Pooling layer
* Input layer layer of ... | """
- - - - - -- - - - - - - - - - - - - - - - - - - - - - -
Name - - CNN - Convolution Neural Network For Photo Recognizing
Goal - - Recognize Handing Writing Word Photo
Detail:Total 5 layers neural network
* Convolution layer
* Pooling layer
* Input layer layer of ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # https://en.wikipedia.org/wiki/Tree_traversal
class Node:
"""
A Node has data variable and pointers to its left and right nodes.
"""
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def make_tree() -> Node:
root = Node(1)
root.left = Nod... | # https://en.wikipedia.org/wiki/Tree_traversal
class Node:
"""
A Node has data variable and pointers to its left and right nodes.
"""
def __init__(self, data):
self.left = None
self.right = None
self.data = data
def make_tree() -> Node:
root = Node(1)
root.left = Nod... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | def actual_power(a: int, b: int):
"""
Function using divide and conquer to calculate a^b.
It only works for integer a,b.
"""
if b == 0:
return 1
if (b % 2) == 0:
return actual_power(a, int(b / 2)) * actual_power(a, int(b / 2))
else:
return a * actual_power(a, int(b / ... | def actual_power(a: int, b: int):
"""
Function using divide and conquer to calculate a^b.
It only works for integer a,b.
"""
if b == 0:
return 1
if (b % 2) == 0:
return actual_power(a, int(b / 2)) * actual_power(a, int(b / 2))
else:
return a * actual_power(a, int(b / ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | def quick_sort_3partition(sorting: list, left: int, right: int) -> None:
if right <= left:
return
a = i = left
b = right
pivot = sorting[left]
while i <= b:
if sorting[i] < pivot:
sorting[a], sorting[i] = sorting[i], sorting[a]
a += 1
i += 1
... | def quick_sort_3partition(sorting: list, left: int, right: int) -> None:
if right <= left:
return
a = i = left
b = right
pivot = sorting[left]
while i <= b:
if sorting[i] < pivot:
sorting[a], sorting[i] = sorting[i], sorting[a]
a += 1
i += 1
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
https://www.hackerrank.com/challenges/abbr/problem
You can perform the following operation on some string, :
1. Capitalize zero or more of 's lowercase letters at some index i
(i.e., make them uppercase).
2. Delete all of the remaining lowercase letters in .
Example:
a=daBcd and b="ABC"
daBcd -> capitalize a a... | """
https://www.hackerrank.com/challenges/abbr/problem
You can perform the following operation on some string, :
1. Capitalize zero or more of 's lowercase letters at some index i
(i.e., make them uppercase).
2. Delete all of the remaining lowercase letters in .
Example:
a=daBcd and b="ABC"
daBcd -> capitalize a a... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Project Euler Problem 5: https://projecteuler.net/problem=5
Smallest multiple
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is _evenly divisible_ by all
of the numbers from 1 to 20?
References:
- https://e... | """
Project Euler Problem 5: https://projecteuler.net/problem=5
Smallest multiple
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is _evenly divisible_ by all
of the numbers from 1 to 20?
References:
- https://e... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # Print all subset combinations of n element in given set of r element.
def combination_util(arr, n, r, index, data, i):
"""
Current combination is ready to be printed, print it
arr[] ---> Input Array
data[] ---> Temporary array to store current combination
start & end ---> Staring and Ending ind... | # Print all subset combinations of n element in given set of r element.
def combination_util(arr, n, r, index, data, i):
"""
Current combination is ready to be printed, print it
arr[] ---> Input Array
data[] ---> Temporary array to store current combination
start & end ---> Staring and Ending ind... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | from collections import deque
def tarjan(g):
"""
Tarjan's algo for finding strongly connected components in a directed graph
Uses two main attributes of each node to track reachability, the index of that node
within a component(index), and the lowest index reachable from that node(lowlink).
We t... | from collections import deque
def tarjan(g):
"""
Tarjan's algo for finding strongly connected components in a directed graph
Uses two main attributes of each node to track reachability, the index of that node
within a component(index), and the lowest index reachable from that node(lowlink).
We t... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
https://en.wikipedia.org/wiki/Combination
"""
from math import factorial
def combinations(n: int, k: int) -> int:
"""
Returns the number of different combinations of k length which can
be made from n values, where n >= k.
Examples:
>>> combinations(10,5)
252
>>> combinations(6,3)
... | """
https://en.wikipedia.org/wiki/Combination
"""
from math import factorial
def combinations(n: int, k: int) -> int:
"""
Returns the number of different combinations of k length which can
be made from n values, where n >= k.
Examples:
>>> combinations(10,5)
252
>>> combinations(6,3)
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # Divide and Conquer algorithm
def find_min(nums, left, right):
"""
find min value in list
:param nums: contains elements
:param left: index of first element
:param right: index of last element
:return: min in nums
>>> nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
>>> find_min(nums, 0, len(num... | # Divide and Conquer algorithm
def find_min(nums, left, right):
"""
find min value in list
:param nums: contains elements
:param left: index of first element
:param right: index of last element
:return: min in nums
>>> nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]
>>> find_min(nums, 0, len(num... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
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,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | import math
class Graph:
def __init__(self, N=0): # a graph with Node 0,1,...,N-1
self.N = N
self.W = [
[math.inf for j in range(0, N)] for i in range(0, N)
] # adjacency matrix for weight
self.dp = [
[math.inf for j in range(0, N)] for i in range(0, N)
... | import math
class Graph:
def __init__(self, N=0): # a graph with Node 0,1,...,N-1
self.N = N
self.W = [
[math.inf for j in range(0, N)] for i in range(0, N)
] # adjacency matrix for weight
self.dp = [
[math.inf for j in range(0, N)] for i in range(0, N)
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Introspective Sort is hybrid sort (Quick Sort + Heap Sort + Insertion Sort)
if the size of the list is under 16, use insertion sort
https://en.wikipedia.org/wiki/Introsort
"""
import math
def insertion_sort(array: list, start: int = 0, end: int = 0) -> list:
"""
>>> array = [4, 2, 6, 8, 1, 7, 8, 22, 14, 5... | """
Introspective Sort is hybrid sort (Quick Sort + Heap Sort + Insertion Sort)
if the size of the list is under 16, use insertion sort
https://en.wikipedia.org/wiki/Introsort
"""
import math
def insertion_sort(array: list, start: int = 0, end: int = 0) -> list:
"""
>>> array = [4, 2, 6, 8, 1, 7, 8, 22, 14, 5... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # This theorem states that the number of prime factors of n
# will be approximately log(log(n)) for most natural numbers n
import math
def exactPrimeFactorCount(n):
"""
>>> exactPrimeFactorCount(51242183)
3
"""
count = 0
if n % 2 == 0:
count += 1
while n % 2 == 0:
... | # This theorem states that the number of prime factors of n
# will be approximately log(log(n)) for most natural numbers n
import math
def exactPrimeFactorCount(n):
"""
>>> exactPrimeFactorCount(51242183)
3
"""
count = 0
if n % 2 == 0:
count += 1
while n % 2 == 0:
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Algorithm that merges two sorted linked lists into one sorted linked list.
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from typing import Optional
test_data_odd = (3, 9, -11, 0, 7, 5, 1, -1)
test_data_even = (4, 6, 2, 0, 8, 10, 3, -2)
@... | """
Algorithm that merges two sorted linked lists into one sorted linked list.
"""
from __future__ import annotations
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from typing import Optional
test_data_odd = (3, 9, -11, 0, 7, 5, 1, -1)
test_data_even = (4, 6, 2, 0, 8, 10, 3, -2)
@... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Project Euler Problem 7: https://projecteuler.net/problem=7
10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we
can see that the 6th prime is 13.
What is the 10001st prime number?
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
def isprime(number: int) -> bool:
... | """
Project Euler Problem 7: https://projecteuler.net/problem=7
10001st prime
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we
can see that the 6th prime is 13.
What is the 10001st prime number?
References:
- https://en.wikipedia.org/wiki/Prime_number
"""
def isprime(number: int) -> bool:
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
One of the several implementations of Lempel–Ziv–Welch decompression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
"""
import math
import sys
def read_file_binary(file_path: str) -> str:
"""
Reads given file as bytes and returns them as a long string
"""
result ... | """
One of the several implementations of Lempel–Ziv–Welch decompression algorithm
https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch
"""
import math
import sys
def read_file_binary(file_path: str) -> str:
"""
Reads given file as bytes and returns them as a long string
"""
result ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | #
| #
| -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | 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,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
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,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Linked Lists consists of Nodes.
Nodes contain data and also may link to other nodes:
- Head Node: First node, the address of the
head node gives us access of the complete list
- Last node: points to null
"""
from typing import Any
class Node:
def __init__(self, item: Any, next: Any) ... | """
Linked Lists consists of Nodes.
Nodes contain data and also may link to other nodes:
- Head Node: First node, the address of the
head node gives us access of the complete list
- Last node: points to null
"""
from typing import Any
class Node:
def __init__(self, item: Any, next: Any) ... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
This script demonstrates the implementation of the ReLU function.
It's a kind of activation function defined as the positive part of its argument in the
context of neural network.
The function takes a vector of K real numbers as input and then argmax(x, 0).
After through ReLU, the element of the vector always 0 or... | """
This script demonstrates the implementation of the ReLU function.
It's a kind of activation function defined as the positive part of its argument in the
context of neural network.
The function takes a vector of K real numbers as input and then argmax(x, 0).
After through ReLU, the element of the vector always 0 or... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """Convert a Decimal Number to a Binary Number."""
def decimal_to_binary(num: int) -> str:
"""
Convert an Integer Decimal Number to a Binary Number as str.
>>> decimal_to_binary(0)
'0b0'
>>> decimal_to_binary(2)
'0b10'
>>> decimal_to_binary(7)
'0b111'
>>> decimal_to_binary(35)
... | """Convert a Decimal Number to a Binary Number."""
def decimal_to_binary(num: int) -> str:
"""
Convert an Integer Decimal Number to a Binary Number as str.
>>> decimal_to_binary(0)
'0b0'
>>> decimal_to_binary(2)
'0b10'
>>> decimal_to_binary(7)
'0b111'
>>> decimal_to_binary(35)
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | from typing import List
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."""
string_rep = []
temp = self
while temp:
string_re... | from typing import List
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."""
string_rep = []
temp = self
while temp:
string_re... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | import math
def perfect_square(num: int) -> bool:
"""
Check if a number is perfect square number or not
:param num: the number to be checked
:return: True if number is square number, otherwise False
>>> perfect_square(9)
True
>>> perfect_square(16)
True
>>> perfect_square(1)
T... | import math
def perfect_square(num: int) -> bool:
"""
Check if a number is perfect square number or not
:param num: the number to be checked
:return: True if number is square number, otherwise False
>>> perfect_square(9)
True
>>> perfect_square(16)
True
>>> perfect_square(1)
T... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # flake8: noqa
"""
Sieve of Eratosthenes
Input : n =10
Output: 2 3 5 7
Input : n = 20
Output: 2 3 5 7 11 13 17 19
you can read in detail about this at
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
"""
def prime_sieve_eratosthenes(num):
"""
print the prime numbers up to n
>>> prime_sieve_eratost... | # flake8: noqa
"""
Sieve of Eratosthenes
Input : n =10
Output: 2 3 5 7
Input : n = 20
Output: 2 3 5 7 11 13 17 19
you can read in detail about this at
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
"""
def prime_sieve_eratosthenes(num):
"""
print the prime numbers up to n
>>> prime_sieve_eratost... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Project Euler Problem 85: https://projecteuler.net/problem=85
By counting carefully it can be seen that a rectangular grid measuring 3 by 2
contains eighteen rectangles.

Although there exists no rectangular grid that contains exactly two million
rectangles, find the area of the grid with the nearest solution.
S... | """
Project Euler Problem 85: https://projecteuler.net/problem=85
By counting carefully it can be seen that a rectangular grid measuring 3 by 2
contains eighteen rectangles.

Although there exists no rectangular grid that contains exactly two million
rectangles, find the area of the grid with the nearest solution.
S... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class LinkedList:
def __init__(self):
self.head = None
def __iter__(self):
node = self.head
while node:
yield node.data
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
def __repr__(self):
return f"Node({self.data})"
class LinkedList:
def __init__(self):
self.head = None
def __iter__(self):
node = self.head
while node:
yield node.data
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
This algorithm (k=33) was first reported by Dan Bernstein many years ago in comp.lang.c
Another version of this algorithm (now favored by Bernstein) uses xor:
hash(i) = hash(i - 1) * 33 ^ str[i];
First Magic constant 33:
It has never been adequately explained.
It's magic because it works better tha... | """
This algorithm (k=33) was first reported by Dan Bernstein many years ago in comp.lang.c
Another version of this algorithm (now favored by Bernstein) uses xor:
hash(i) = hash(i - 1) * 33 ^ str[i];
First Magic constant 33:
It has never been adequately explained.
It's magic because it works better tha... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Project Euler Problem 6: https://projecteuler.net/problem=6
Sum square difference
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of... | """
Project Euler Problem 6: https://projecteuler.net/problem=6
Sum square difference
The sum of the squares of the first ten natural numbers is,
1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)^2 = 55^2 = 3025
Hence the difference between the sum of... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # An island in matrix is a group of linked areas, all having the same value.
# This code counts number of islands in a given matrix, with including diagonal
# connections.
class matrix: # Public class to implement a graph
def __init__(self, row: int, col: int, graph: list):
self.ROW = row
self.CO... | # An island in matrix is a group of linked areas, all having the same value.
# This code counts number of islands in a given matrix, with including diagonal
# connections.
class matrix: # Public class to implement a graph
def __init__(self, row: int, col: int, graph: list):
self.ROW = row
self.CO... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
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,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | #
| #
| -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
Similarity Search : https://en.wikipedia.org/wiki/Similarity_search
Similarity search is a search algorithm for finding the nearest vector from
vectors, used in natural language processing.
In this algorithm, it calculates distance with euclidean distance and
returns a list containing two data for each vector:
... | """
Similarity Search : https://en.wikipedia.org/wiki/Similarity_search
Similarity search is a search algorithm for finding the nearest vector from
vectors, used in natural language processing.
In this algorithm, it calculates distance with euclidean distance and
returns a list containing two data for each vector:
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # Welcome to Quantum Algorithms
Started at https://github.com/TheAlgorithms/Python/issues/1831
* D-Wave: https://www.dwavesys.com and https://github.com/dwavesystems
* Google: https://research.google/teams/applied-science/quantum
* IBM: https://qiskit.org and https://github.com/Qiskit
* Rigetti: https://rigetti.com a... | # Welcome to Quantum Algorithms
Started at https://github.com/TheAlgorithms/Python/issues/1831
* D-Wave: https://www.dwavesys.com and https://github.com/dwavesystems
* Google: https://research.google/teams/applied-science/quantum
* IBM: https://qiskit.org and https://github.com/Qiskit
* Rigetti: https://rigetti.com a... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | """
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,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # https://www.geeksforgeeks.org/newton-forward-backward-interpolation/
import math
from typing import List
# for calculating u value
def ucal(u: float, p: int) -> float:
"""
>>> ucal(1, 2)
0
>>> ucal(1.1, 2)
0.11000000000000011
>>> ucal(1.2, 2)
0.23999999999999994
"""
temp = u
... | # https://www.geeksforgeeks.org/newton-forward-backward-interpolation/
import math
from typing import List
# for calculating u value
def ucal(u: float, p: int) -> float:
"""
>>> ucal(1, 2)
0
>>> ucal(1.1, 2)
0.11000000000000011
>>> ucal(1.2, 2)
0.23999999999999994
"""
temp = u
... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # Algorithms to determine if a string is palindrome
test_data = {
"MALAYALAM": True,
"String": False,
"rotor": True,
"level": True,
"A": True,
"BB": True,
"ABC": False,
"amanaplanacanalpanama": True, # "a man a plan a canal panama"
}
# Ensure our test data is valid
assert all((key == k... | # Algorithms to determine if a string is palindrome
test_data = {
"MALAYALAM": True,
"String": False,
"rotor": True,
"level": True,
"A": True,
"BB": True,
"ABC": False,
"amanaplanacanalpanama": True, # "a man a plan a canal panama"
}
# Ensure our test data is valid
assert all((key == k... | -1 |
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | -1 | ||
TheAlgorithms/Python | 4,292 | [mypy] fix small folders | ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohms_law.py: I added a final ... | algobytewise | 2021-03-23T07:05:28Z | 2021-03-23T15:51:50Z | a8db5d4b93410d8ad3c281d1edd9ce26c6e087e0 | 959507901ac8f10cd605c51c305d13b27d105536 | [mypy] fix small folders. ### **Describe your change:**
Related Issue: #4052
comment for strassen_matrix_multiplication.py: I couldn't use Tuple as return type since one branch of the function returns a tuple an another a list/matrix. So I turned the tuple into a list instead.
comment for electric_power.py & ohm... | # Information on binary shifts:
# https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types
# https://www.interviewcake.com/concept/java/bit-shift
def logical_left_shift(number: int, shift_amount: int) -> str:
"""
Take in 2 positive integers.
'number' is the integer to be logical... | # Information on binary shifts:
# https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types
# https://www.interviewcake.com/concept/java/bit-shift
def logical_left_shift(number: int, shift_amount: int) -> str:
"""
Take in 2 positive integers.
'number' is the integer to be logical... | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.