MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

Method__str__
:return: passcode of the cipher object
ciphers/shuffled_shift_cipher.py:41
Method__str__
>>> str(Node(1, 2)) 'Node(key=1, freq=2)'
dynamic_programming/optimal_binary_search_tree.py:30
Method__sub__
(self, other: Variable)
machine_learning/automatic_differentiation.py:74
Method__sub__
input: other vector assumes: other vector has the same size returns a new vector that represents the difference.
linear_algebra/src/lib.py:85
Method__sub__
implements matrix subtraction.
linear_algebra/src/lib.py:303
Method__sub__
(self, other)
maths/dual_number_automatic_differentiation.py:45
Method__sub__
Polynomial subtraction >>> p = Polynomial(2, [1, 2, 4]) >>> q = Polynomial(2, [1, 2, 3]) >>> p - q 1x^2
maths/polynomials/single_indeterminate_operations.py:54
Method__sub__
(self, other: Matrix)
matrix/matrix_class.py:308
Method__sub__
(self, another: Matrix)
matrix/sherman_morrison.py:146
Method__truediv__
(self, other: Variable)
machine_learning/automatic_differentiation.py:92
Method__truediv__
(self, other)
maths/dual_number_automatic_differentiation.py:66
Method_algorithm
(self)
graphs/edmonds_karp_multiple_source_and_sink.py:103
Method_collision_resolution
(self, key, data=None)
data_structures/hashing/hash_table_with_linked_list.py:22
Method_collision_resolution
Examples: 1. Try to add three data elements when the size is three >>> dh = DoubleHash(3) >>> dh.insert_data(10)
data_structures/hashing/double_hash.py:38
Method_collision_resolution
Quadratic probing is an open addressing scheme used for resolving collisions in hash table. It works by taking the original
data_structures/hashing/quadratic_probing.py:14
Method_delete
(curr: TrieNode, word: str, index: int)
data_structures/trie/trie.py:56
Method_if
Shape Index https://www.indexdatabase.de/db/i-single.php?id=79 :return: index
digital_image_processing/index_calculation.py:503
Method_k
(self, i1, i2)
machine_learning/sequential_minimum_optimization.py:171
Method_linear
(self, v1, v2)
machine_learning/sequential_minimum_optimization.py:416
Method_polynomial
(self, v1, v2)
machine_learning/sequential_minimum_optimization.py:413
Method_rbf
(self, v1, v2)
machine_learning/sequential_minimum_optimization.py:419
Method_set_value
(self, key, data)
data_structures/hashing/hash_table_with_linked_list.py:10
Functionabbr
>>> abbr("daBcd", "ABC") True >>> abbr("dBcd", "ABC") False
dynamic_programming/abbreviation.py:15
Functionadd_binary_prefix
Function that converts a number to his version with Binary prefix @input value (an integer) @example: >>> add_binary_prefix(65536)
conversions/prefix_conversions_string.py:103
Methodadd_edge
(self, node1: T, node2: T, weight: int)
graphs/minimum_spanning_tree_prims2.py:212
Methodadd_edge
Adds an edge in the format [first, second, edge weight] to graph.
graphs/boruvka.py:49
Methodadd_edge
>>> g = AdjacencyList(2) >>> g.add_edge(0, 1, 0) >>> g.add_edge(1, 0, 1) >>> list(g[0]) [Edge(destination_ver
graphs/breadth_first_search_zero_one_shortest_path.py:37
Methodadd_edge
Connects vertices together. Creates and Edge from source vertex to destination vertex. Vertices will be created if not found
graphs/graph_list.py:84
Methodadd_first
insertion in the front >>> LinkedDeque().add_first('AV').first() 'AV'
data_structures/linked_list/deque_doubly.py:89
Methodadd_last
insertion in the end >>> LinkedDeque().add_last('B').last() 'B'
data_structures/linked_list/deque_doubly.py:96
Functionadd_si_prefix
Function that converts a number to his version with SI prefix @input value (an integer) @example: >>> add_si_prefix(10000) '10.0
conversions/prefix_conversions_string.py:87
Functionadditive_persistence
Return the persistence of a given number. https://en.wikipedia.org/wiki/Persistence_of_a_number >>> additive_persistence(199) 3
maths/persistence.py:40
Functionadjm
r""" Reading an Adjacency matrix Parameters: None Returns: tuple: A tuple containing a list of edges and number of edges
graphs/basic_graphs.py:219
Functionadler32
Function implements adler-32 hash. Iterates and evaluates a new value for each character >>> adler32('Algorithms') 363791387 >>
hashes/adler32.py:14
Functionaliquot_sum
Finds the aliquot sum of an input integer, where the aliquot sum of a number n is defined as the sum of all natural numbers less than n t
maths/aliquot_sum.py:1
Methodall_nodes
(self)
graphs/directed_and_undirected_weighted_graph.py:25
Methodall_nodes
(self)
graphs/directed_and_undirected_weighted_graph.py:476
Functionallocation_num
Divide a number of bytes into x partitions. :param number_of_bytes: the total of bytes. :param partitions: the number of partition need t
maths/allocation_number.py:12
Functionalphanum_key
(key)
sorts/natural_sort.py:27
Functionalt_ipv4_to_decimal
>>> alt_ipv4_to_decimal("192.168.0.1") 3232235521 >>> alt_ipv4_to_decimal("10.0.0.255") 167772415
conversions/ipv4_conversion.py:41
Functionand_gate
Calculate AND of the input values >>> and_gate(0, 0) 0 >>> and_gate(0, 1) 0 >>> and_gate(1, 0) 0 >>> and_gate(1, 1)
boolean_algebra/and_gate.py:19
Functionapparent_power
Calculate the apparent power in a single-phase AC circuit. Reference: https://en.wikipedia.org/wiki/AC_power#Apparent_power >>> apparen
electronics/apparent_power.py:5
Functionapproximately_equal_hsv
Utility-function to check that two hsv-colors are approximately equal >>> approximately_equal_hsv([0, 0, 0], [0, 0, 0]) True >>> app
conversions/rgb_hsv_conversion.py:142
Functionapr_interest
>>> apr_interest(10000.0, 0.05, 3) 1618.223072263547 >>> apr_interest(10000.0, 0.05, 1) 512.6749646744732 >>> apr_interest(0.5, 0
financial/interest.py:80
Functionarchimedes_principle
Args: fluid_density: density of fluid (kg/m^3) volume: volume of object/liquid being displaced by the object (m^3) gravit
physics/archimedes_principle_of_buoyant_force.py:15
Functionare_collinear
Check if three points are collinear or not. 1- Create two vectors AB and AC. 2- Get the cross vector of the two vectors. 3- Calculat
maths/points_are_collinear_3d.py:96
Methodarea
>>> Ellipse(5, 10).area 157.07963267948966
geometry/geometry.py:95
Methodarea
(self)
geometry/geometry.py:261
Methodarea
(self)
geometry/geometry.py:283
Functionarea_under_line_estimator_check
Checks estimation error for area_under_curve_estimator function for f(x) = x where x lies within min_value to max_value 1. Calls "area_un
maths/monte_carlo.py:71
Functionarithmetic_mean
return the arithmetic mean of series >>> arithmetic_mean([2, 4, 6]) 4.0 >>> arithmetic_mean([3, 6, 9, 12]) 7.5 >>> arithmeti
maths/series/arithmetic.py:42
Functionarithmetic_right_shift
Take in 2 integers. 'number' is the integer to be arithmetically right shifted 'shift_amount' times. i.e. (number >> shift_amount) Re
bit_manipulation/binary_shifts.py:68
Functionarray_equalization
This algorithm equalizes all elements of the input vector to a common value, by making the minimal number of "updates" under the constrai
matrix/matrix_equalization.py:4
Methodarv12
Atmospherically Resistant Vegetation Index 2 https://www.indexdatabase.de/db/i-single.php?id=396 :return: index -
digital_image_processing/index_calculation.py:180
Functionascii85_decode
>>> ascii85_decode(b"") b'' >>> ascii85_decode(b"0etOA2#") b'12345' >>> ascii85_decode(b"@UX=h+?24") b'base 85'
ciphers/base85.py:33
Functionascii85_encode
>>> ascii85_encode(b"") b'' >>> ascii85_encode(b"12345") b'0etOA2#' >>> ascii85_encode(b"base 85") b'@UX=h+?24'
ciphers/base85.py:16
Functionastable_duty_cycle
Usage examples: >>> astable_duty_cycle(resistance_1=45, resistance_2=45) 66.66666666666666 >>> astable_duty_cycle(resistance_1=356, r
electronics/ic_555_timer.py:50
Functionastable_frequency
Usage examples: >>> astable_frequency(resistance_1=45, resistance_2=45, capacitance=7) 1523.8095238095239 >>> astable_frequency(resis
electronics/ic_555_timer.py:26
Functionatbash_slow
>>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC'
ciphers/atbash.py:6
Methodatsavi
Adjusted transformed soil-adjusted VI https://www.indexdatabase.de/db/i-single.php?id=209 :return: index
digital_image_processing/index_calculation.py:289
Functionaverage_absolute_deviation
Return the average absolute deviation of a list of numbers. Wiki: https://en.wikipedia.org/wiki/Average_absolute_deviation >>> average_a
maths/average_absolute_deviation.py:1
Functionavg_speed_of_molecule
Takes the temperature (in K) and molar mass (in kg/mol) of a gas and returns the average speed of a molecule in the gas (in m/s). Exampl
physics/speeds_of_gas_molecules.py:54
Methodbad_character_heuristic
Finds the positions of the pattern location. >>> bms = BoyerMooreSearch(text="ABAABA", pattern="AB") >>> bms.bad_character_h
strings/boyer_moore_search.py:79
Functionbailey_borwein_plouffe
Implement a popular pi-digit-extraction algorithm known as the Bailey-Borwein-Plouffe (BBP) formula to calculate the nth hex digit of pi.
maths/bailey_borwein_plouffe.py:1
Methodbalanced_factor
(self)
data_structures/hashing/hash_table_with_linked_list.py:15
Functionbase16_decode
Decodes the given base16 encoded data into bytes. >>> base16_decode('48656C6C6F20576F726C6421') b'Hello World!' >>> base16_decode('4
ciphers/base16.py:18
Functionbase16_encode
Encodes the given bytes into base16. >>> base16_encode(b'Hello World!') '48656C6C6F20576F726C6421' >>> base16_encode(b'HELLO WORLD!'
ciphers/base16.py:1
Functionbase32_decode
>>> base32_decode(b'JBSWY3DPEBLW64TMMQQQ====') b'Hello World!' >>> base32_decode(b'GEZDGNBVGY======') b'123456' >>> base32_decode
ciphers/base32.py:26
Functionbase32_encode
>>> base32_encode(b"Hello World!") b'JBSWY3DPEBLW64TMMQQQ====' >>> base32_encode(b"123456") b'GEZDGNBVGY======' >>> base32_encode
ciphers/base32.py:10
Functionbase64_decode
Decodes data according to RFC4648. This does the reverse operation of base64_encode. We first transform the encoded data back to a binary str
ciphers/base64_cipher.py:64
Functionbase64_encode
Encodes data according to RFC4648. The data is first transformed to binary and appended with binary digits so that its length becomes a multi
ciphers/base64_cipher.py:4
Functionbell_numbers
Calculate Bell numbers for the sets of lengths from 0 to max_set_length. In other words, calculate first (max_set_length + 1) Bell numbers.
maths/special_numbers/bell_numbers.py:11
Functionbenchmark
Benchmark code comparing two different version function.
project_euler/problem_009/sol1.py:62
Functionbfs
>>> bfs({1: [2, 3], 2: [4, 5], 3: [6, 7], 4: [], 5: [8], 6: [], 7: [], 8: []}, 1) 1 2 3 4 5 6 7 8
graphs/basic_graphs.py:114
Methodbfs_time
(self, s=-2)
graphs/directed_and_undirected_weighted_graph.py:257
Methodbfs_time
(self, s=-2)
graphs/directed_and_undirected_weighted_graph.py:485
Functionbidirectional_dij
Bi-directional Dijkstra's algorithm. Returns: shortest_path_distance (int): length of the shortest path. Warnings: If t
graphs/bi_directional_dijkstra.py:47
Functionbin_to_decimal
Convert a binary value to its decimal equivalent >>> bin_to_decimal("101") 5 >>> bin_to_decimal(" 1010 ") 10 >>> bin_to_de
conversions/binary_to_decimal.py:1
Functionbin_to_hexadecimal
Converting a binary string into hexadecimal using Grouping Method >>> bin_to_hexadecimal('101011111') '0x15f' >>> bin_to_hexadecimal
conversions/binary_to_hexadecimal.py:21
Functionbin_to_octal
(bin_string: str)
conversions/binary_to_octal.py:21
Functionbinary_and
Take in 2 integers, convert them to binary, return a binary number that is the result of a binary and operation on the integers provided.
bit_manipulation/binary_and_operator.py:4
Functionbinary_coded_decimal
Find binary coded decimal (bcd) of integer base 10. Each digit of the number is represented by a 4-bit binary. Example: >>> binary_co
bit_manipulation/binary_coded_decimal.py:1
Functionbinary_count_setbits
Take in 1 integer, return a number that is the number of 1's in binary representation of that number. >>> binary_count_setbits(25) 3
bit_manipulation/binary_count_setbits.py:1
Functionbinary_count_trailing_zeros
Take in 1 integer, return a number that is the number of trailing zeros in binary representation of that number. >>> binary_count_traili
bit_manipulation/binary_count_trailing_zeros.py:4
Functionbinary_cross_entropy
Calculate the mean binary cross-entropy (BCE) loss between true labels and predicted probabilities. BCE loss quantifies dissimilarity be
machine_learning/loss_functions.py:4
Functionbinary_exp_iterative
Computes a^b iteratively, where a is the base and b is the exponent >>> binary_exp_iterative(3, 5) 243 >>> binary_exp_iterative(11,
maths/binary_exponentiation.py:53
Functionbinary_exp_mod_iterative
Computes a^b % c iteratively, where a is the base, b is the exponent, and c is the modulus >>> binary_exp_mod_iterative(3, 4, 5) 1
maths/binary_exponentiation.py:125
Functionbinary_exp_mod_recursive
Computes a^b % c recursively, where a is the base, b is the exponent, and c is the modulus >>> binary_exp_mod_recursive(3, 4, 5) 1
maths/binary_exponentiation.py:90
Functionbinary_exp_recursive
Computes a^b recursively, where a is the base and b is the exponent >>> binary_exp_recursive(3, 5) 243 >>> binary_exp_recursive(11,
maths/binary_exponentiation.py:17
Functionbinary_focal_cross_entropy
Calculate the mean binary focal cross-entropy (BFCE) loss between true labels and predicted probabilities. BFCE loss quantifies dissimil
machine_learning/loss_functions.py:42
Functionbinary_mod_multiply
Calculate (a * b) % c using binary multiplication and modular arithmetic. Parameters: a (int): The first number. b (int): The second
maths/binary_multiplication.py:61
Functionbinary_multiply
Multiply 'a' and 'b' using bitwise multiplication. Parameters: a (int): The first number. b (int): The second number. Returns:
maths/binary_multiplication.py:23
Functionbinary_or
Take in 2 integers, convert them to binary, and return a binary number that is the result of a binary or operation on the integers provided
bit_manipulation/binary_or_operator.py:4
Functionbinary_search_std_lib
Pure implementation of a binary search algorithm in Python using stdlib Be careful collection must be ascending sorted otherwise, the result will
searches/binary_search.py:217
Functionbinary_search_with_duplicates
Pure implementation of a binary search algorithm in Python that supports duplicates. Resources used: https://stackoverflow.com/questions/
searches/binary_search.py:245
Functionbinary_step
Implements the binary step function Parameters: vector (ndarray): A vector that consists of numeric values Returns: vec
neural_network/activation_functions/binary_step.py:14
Functionbinary_tree_bottom_side_view
r""" Function returns the bottom side view of binary tree 3 / \ 9 20 / \ 15 7 ↑ ↑ ↑ ↑ 9 15 20 7 >
data_structures/binary_tree/diff_views_of_binary_tree.py:159
Functionbinary_tree_left_side_view
r""" Function returns the left side view of binary tree. 3 -> 3 / \ 9 -> 9 20 / \ 15 -> 15 7
data_structures/binary_tree/diff_views_of_binary_tree.py:70
Functionbinary_tree_right_side_view
r""" Function returns the right side view of binary tree. 3 <- 3 / \ 9 20 <- 20 / \ 15 7 <- 7
data_structures/binary_tree/diff_views_of_binary_tree.py:30
Functionbinary_tree_top_side_view
r""" Function returns the top side view of binary tree. 9 3 20 7 ⬇ ⬇ ⬇ ⬇ 3 / \ 9 20 / \ 15 7 >>>
data_structures/binary_tree/diff_views_of_binary_tree.py:110
← previousnext →2,801–2,900 of 3,909, ranked by callers