MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

Functiongravitational_law
Input Parameters ---------------- force : magnitude in Newtons mass_1 : mass in Kilograms mass_2 : mass in Kilograms dista
physics/newtons_law_of_gravitation.py:28
Functiongray_code
Takes in an integer n and returns a n-bit gray code sequence An n-bit gray code sequence is a sequence of 2^n integers where: a)
bit_manipulation/gray_code_sequence.py:1
Functiongreatest_prime_factor
input: positive integer 'number' >= 0 returns the greatest prime number factor of 'number' >>> greatest_prime_factor(0) 0 >>> gr
maths/primelib.py:235
Functiongreedy
(item, max_cost, key_func)
other/greedy.py:30
Methodgrndvi
self.green-self.red NDVI https://www.indexdatabase.de/db/i-single.php?id=185 :return: index
digital_image_processing/index_calculation.py:261
Functiongronsfeld
Encrypt plaintext with the Gronsfeld cipher >>> gronsfeld('hello', '412') 'LFNPP' >>> gronsfeld('hello', '123') 'IGOMQ' >>>
ciphers/gronsfeld_cipher.py:4
Methodgsavi
self.green Soil Adjusted Vegetation Index https://www.indexdatabase.de/db/i-single.php?id=31 mit N = 0,5 :return: ind
digital_image_processing/index_calculation.py:379
Functionh_index
Return H-index of citations >>> h_index([3, 0, 6, 1, 5]) 3 >>> h_index([1, 3, 1]) 1 >>> h_index([1, 2, 3]) 2 >>> h_i
other/h_index.py:28
Functionhamilton_cycle
r""" Wrapper function to call subroutine called util_hamilton_cycle, which will either return array of vertices indicating hamiltonian cycle
backtracking/hamiltonian_cycle.py:110
Functionhamming_distance
Calculate the Hamming distance between two equal length strings In information theory, the Hamming distance between two strings of equal lengt
strings/hamming_distance.py:1
Methodhand
Returns the self hand
project_euler/problem_054/sol1.py:137
Methodhand_name
Return the name of the hand in the following format: 'hand name, high card' Here are some examples: >>> PokerHand("K
project_euler/problem_054/sol1.py:187
Methodhandle_starttag
This function parse html to take takes url from tags
web_programming/emails_from_url.py:32
Functionharmonic_mean
return the harmonic mean of series >>> harmonic_mean([1, 4, 4]) 2.0 >>> harmonic_mean([3, 6, 9, 12]) 5.759999999999999 >>> h
maths/series/harmonic.py:59
Functionharshad_numbers_in_base
Finds all Harshad numbers smaller than num in base 'base'. Where 'base' ranges from 2 to 36. Examples: >>> harshad_numbers_in_base(1
maths/special_numbers/harshad_numbers.py:89
Methodhas_cycle
(self)
graphs/directed_and_undirected_weighted_graph.py:199
Methodhas_cycle
(self)
graphs/directed_and_undirected_weighted_graph.py:424
Methodhas_loop
A loop is when the exact same Node appears more than once in a linked list. >>> root_node = Node(1) >>> root_node.next_node =
data_structures/linked_list/has_loop.py:26
Methodhas_next_and_prev
(self)
data_structures/linked_list/deque_doubly.py:22
Methodhelper_mean_squared_error_test
helper_mean_squared_error_test: @param labels: a one dimensional numpy array @param prediction: a floating point value
machine_learning/decision_tree.py:162
Functionheuristic_1
(p: TPos, goal: TPos)
graphs/multi_heuristic_astar.py:71
Functionheuristic_2
(p: TPos, goal: TPos)
graphs/multi_heuristic_astar.py:66
Functionhex_to_bin
Convert a hexadecimal value to its binary equivalent #https://stackoverflow.com/questions/1425493/convert-hex-to-binary Here, we have use
conversions/hex_to_bin.py:1
Functionhex_to_decimal
Convert a hexadecimal value to its decimal equivalent #https://www.programiz.com/python-programming/methods/built-in/hex >>> hex_to_deci
conversions/hexadecimal_to_decimal.py:4
Functionhexagonal
:param number: nth hexagonal number to calculate :return: the nth hexagonal number Note: A hexagonal number is only defined for positive
maths/special_numbers/hexagonal_number.py:14
Functionhinge_loss
Calculate the mean hinge loss for between true labels and predicted probabilities for training support vector machines (SVMs). Hinge los
machine_learning/loss_functions.py:253
Functionhorn_schunck
This function performs the Horn-Schunck algorithm and returns the estimated optical flow. It is assumed that the input images are grayscale a
computer_vision/horn_schunck.py:61
Functionhsv_to_rgb
Conversion from the HSV-representation to the RGB-representation. Expected RGB-values taken from https://www.rapidtables.com/convert/colo
conversions/rgb_hsv_conversion.py:15
Functionhuber_loss
Calculate the mean Huber loss between the given ground truth and predicted values. The Huber loss describes the penalty incurred by an estim
machine_learning/loss_functions.py:293
Methodhue
Hue https://www.indexdatabase.de/db/i-single.php?id=34 :return: index
digital_image_processing/index_calculation.py:388
Methodi
Intensity https://www.indexdatabase.de/db/i-single.php?id=36 :return: index
digital_image_processing/index_calculation.py:416
Functionidentity_function
Represents identity function >>> [function_to_integrate(x) for x in [-2.0, -1.0, 0.0, 1.0, 2.0]] [-2.0, -1.0, 0.0, 1.0, 2.0]
maths/monte_carlo.py:82
Functionimage_distance
Doctests: >>> from math import isclose >>> isclose(image_distance(50,40), 22.22222222222222) True >>> from math import isclose
physics/lens_formulae.py:108
Functionimage_distance
>>> from math import isclose >>> isclose(image_distance(10, 40), 13.33333333) True >>> from math import isclose >>> isclose(image
physics/mirror_formulae.py:107
Methodimages
(self)
neural_network/input_data.py:185
Methodin_degree
(self, u)
graphs/directed_and_undirected_weighted_graph.py:102
Functionind_reactance
Calculate inductive reactance, frequency or inductance from two given electrical properties then return name/value pair of the zero value in
electronics/ind_reactance.py:7
Functionindex_2d_array_in_1d
Retrieves the value of the one-dimensional index from a two-dimensional array. Args: array: A 2D array of integers where all rows ar
data_structures/arrays/index_2d_array_in_1d.py:62
Functioninitialize_unweighted_directed_graph
( node_count: int, edge_count: int )
graphs/basic_graphs.py:8
Functioninitialize_unweighted_undirected_graph
( node_count: int, edge_count: int )
graphs/basic_graphs.py:21
Functioninitialize_weighted_undirected_graph
( node_count: int, edge_count: int )
graphs/basic_graphs.py:35
Functioninorder
inorder (left, self, right)
data_structures/binary_tree/binary_search_tree.py:333
Functioninorder
Just recursive print of a tree
data_structures/binary_tree/treap.py:109
Methodinsert
(self, value: DataType)
data_structures/linked_list/doubly_linked_list_two.py:92
Methodinsert
insert a value in the heap
data_structures/heap/binomial_heap.py:206
Methodinsert
(self, node)
data_structures/heap/min_heap.py:117
Methodinsert
(self, *values)
data_structures/binary_tree/binary_search_tree.py:195
Methodinsert_at_position
(self, position: int, value: DataType)
data_structures/linked_list/doubly_linked_list_two.py:121
Methodinsert_east
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_east("cat", [1], [0]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE [
other/word_search.py:106
Methodinsert_item
Inserts given item with given value in heap
data_structures/heap/heap_generic.py:105
Methodinsert_north
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_north("cat", [2], [2]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:36
Methodinsert_northeast
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_northeast("cat", [2], [0]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:68
Methodinsert_northwest
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_northwest("cat", [2], [2]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:278
Methodinsert_south
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_south("cat", [0], [0]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:176
Methodinsert_southeast
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_southeast("cat", [0], [0]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:138
Methodinsert_southwest
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_southwest("cat", [0], [2]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE
other/word_search.py:208
Methodinsert_west
>>> ws = WordSearch(WORDS, 3, 3) >>> ws.insert_west("cat", [1], [2]) >>> ws.board # doctest: +NORMALIZE_WHITESPACE [
other/word_search.py:246
Functioninsort_left
Inserts a given value into a sorted array before other values with the same value. It has the same interface as https://docs.python.org/
searches/binary_search.py:100
Functioninsort_right
Inserts a given value into a sorted array after other values with the same value. It has the same interface as https://docs.python.org/3
searches/binary_search.py:140
Functionint_to_roman
Given a integer, convert it to an roman numeral. https://en.wikipedia.org/wiki/Roman_numerals >>> tests = {"III": 3, "CLIV": 154, "MIX
conversions/roman_numerals.py:41
Functioninteger_square_root
Returns the integer square root of a non-negative integer num. Args: num: A non-negative integer. Returns: The integer sq
maths/integer_square_root.py:16
Methodintegral
Returns the integral of the polynomial. >>> p = Polynomial(2, [1, 2, 3]) >>> p.integral() 1.0x^3 + 1.0x^2 + 1.0x
maths/polynomials/single_indeterminate_operations.py:147
Functionintegrand
(x: float, z: float)
maths/gamma.py:50
Functioninterpolated_func
>>> interpolate([1])(3) 1 >>> interpolate([1, 8])(3) 15 >>> interpolate([1, 8, 27])(4) 58 >>>
project_euler/problem_101/sol1.py:145
Functioninterpolation_search
Searches for an item in a sorted collection by interpolation search algorithm. Args: sorted_collection: sorted list of integers
searches/interpolation_search.py:6
Functioninterpolation_search_by_recursion
Pure implementation of interpolation search algorithm in Python by recursion Be careful collection must be ascending sorted, otherwise result will
searches/interpolation_search.py:76
Functioninterquartile_range
Return the interquartile range for a list of numeric values. :param nums: The list of numeric values. :return: interquartile range >
maths/interquartile_range.py:34
Functioninterquartile_range_checker
Optional method: interquatile range input : list of total user in float output : low limit of input in float this method can be used
machine_learning/forecasting/run.py:81
Functioninverse_document_frequency
Return an integer denoting the importance of a word. This measure of importance is calculated by log10(N/df), where N is the number o
machine_learning/word_frequency_functions.py:86
Functioninverse_of_matrix
A matrix multiplied with its inverse gives the identity matrix. This function finds the inverse of a 2x2 and 3x3 matrix. If the determ
matrix/inverse_of_matrix.py:8
Functionipv4_to_decimal
Convert an IPv4 address to its decimal representation. Args: ip_address: A string representing an IPv4 address (e.g., "192.168.0.1")
conversions/ipv4_conversion.py:4
Methodipvi
Infraself.red percentage vegetation index https://www.indexdatabase.de/db/i-single.php?id=35 :return: index
digital_image_processing/index_calculation.py:408
Functionis_arithmetic_series
checking whether the input series is arithmetic series or not >>> is_arithmetic_series([2, 4, 6]) True >>> is_arithmetic_series([3, 6
maths/series/arithmetic.py:11
Functionis_automorphic_number
# doctest: +NORMALIZE_WHITESPACE This functions takes an integer number as input. returns True if the number is automorphic. >>> is_a
maths/special_numbers/automorphic_number.py:14
Functionis_bipartite_bfs
Check if a graph is bipartite using a breadth-first search (BFS). Args: `graph`: Adjacency list representing the graph. Returns
graphs/check_bipatrite.py:84
Functionis_bipartite_dfs
Check if a graph is bipartite using depth-first search (DFS). Args: `graph`: Adjacency list representing the graph. Returns:
graphs/check_bipatrite.py:4
Functionis_bit_set
Is the bit at position set? Details: Shift the bit at position to be the first (smallest) bit. Then check if the first bit is set by and
bit_manipulation/single_bit_manipulation_operations.py:56
Functionis_contains_unique_chars
Check if all characters in the string is unique or not. >>> is_contains_unique_chars("I_love.py") True >>> is_contains_unique_chars("
strings/is_contains_unique_chars.py:1
Methodis_empty
(self)
data_structures/linked_list/doubly_linked_list_two.py:162
Methodis_empty
(self)
data_structures/heap/min_heap.py:123
Functionis_english
>>> is_english('Hello World') True >>> is_english('llold HorWd') False
strings/detecting_english_programmatically.py:43
Functionis_even
return true if the input integer is even Explanation: Lets take a look at the following decimal to binary conversions 2 => 10 14 => 1
bit_manipulation/is_even.py:1
Methodis_full
Returns True if the tree is full >>> BinaryTree(Node(1)).is_full() True >>> BinaryTree.small_tree().is_full()
data_structures/binary_tree/basic_binary_tree.py:93
Functionis_geometric_series
checking whether the input series is geometric series or not >>> is_geometric_series([2, 4, 8]) True >>> is_geometric_series([3, 6, 1
maths/series/geometric.py:10
Functionis_germain_prime
Checks if input number and 2*number + 1 are prime. >>> is_germain_prime(3) True >>> is_germain_prime(11) True >>> is_germain_prim
maths/germain_primes.py:14
Functionis_happy_number
A happy number is a number which eventually reaches 1 when replaced by the sum of the square of each digit. :param number: The numbe
maths/special_numbers/happy_number.py:1
Functionis_harmonic_series
checking whether the input series is arithmetic series or not >>> is_harmonic_series([ 1, 2/3, 1/2, 2/5, 1/3]) True >>> is_harmonic_s
maths/series/harmonic.py:10
Functionis_harshad_number_in_base
Determines whether n in base 'base' is a harshad number. Where 'base' ranges from 2 to 36. Examples: >>> is_harshad_number_in_base(1
maths/special_numbers/harshad_numbers.py:129
Functionis_int_palindrome
Returns whether `num` is a palindrome or not (see for reference https://en.wikipedia.org/wiki/Palindromic_number). >>> is_int_palindrome
maths/is_int_palindrome.py:1
Functionis_odd
input: integer 'number' returns true if 'number' is odd, otherwise false. >>> is_odd(0) False >>> is_odd(8) False >>> is
maths/primelib.py:348
Functionis_palindrome
Check if a linked list is a palindrome. Args: head: The head of the linked list. Returns: bool: True if the linked list
data_structures/linked_list/is_palindrome.py:12
Functionis_palindrome_dict
Check if a linked list is a palindrome using a dictionary. Args: head (ListNode): The head of the linked list. Returns:
data_structures/linked_list/is_palindrome.py:124
Functionis_palindrome_stack
Check if a linked list is a palindrome using a stack. Args: head (ListNode): The head of the linked list. Returns: bool
data_structures/linked_list/is_palindrome.py:68
Functionis_palindrome_traversal
Return True if s is a palindrome otherwise return False. >>> all(is_palindrome_traversal(key) == value for key, value in test_data.items())
strings/palindrome.py:40
Functionis_pangram
A Pangram String contains all the alphabets at least once. >>> is_pangram("The quick brown fox jumps over the lazy dog") True >>> is_
strings/is_pangram.py:6
Functionis_pangram_faster
>>> is_pangram_faster("The quick brown fox jumps over the lazy dog") True >>> is_pangram_faster("Waltz, bad nymph, for quick jigs vex.")
strings/is_pangram.py:35
Functionis_pangram_fastest
>>> is_pangram_fastest("The quick brown fox jumps over the lazy dog") True >>> is_pangram_fastest("Waltz, bad nymph, for quick jigs vex."
strings/is_pangram.py:59
Functionis_perfect_number
input: positive integer 'number' > 1 returns true if 'number' is a perfect number otherwise false. >>> is_perfect_number(28) True
maths/primelib.py:688
Functionis_polish_national_id
Verification of the correctness of the PESEL number. www-gov-pl.translate.goog/web/gov/czym-jest-numer-pesel?_x_tr_sl=auto&_x_tr_tl=en
strings/is_polish_national_id.py:1
Functionis_power_of_two
Return True if this number is power of 2 or False otherwise. >>> is_power_of_two(0) True >>> is_power_of_two(1) True >>> is_
bit_manipulation/is_power_of_two.py:18
← previousnext →3,201–3,300 of 3,909, ranked by callers