MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 1 callersFunctionis_valid_email_address
Returns True if the passed email address is valid. The local part of the email precedes the singular @ symbol and is associated with a d
strings/is_valid_email_address.py:43
↓ 1 callersMethodis_valid_public_key
(self, key: int)
ciphers/diffie_hellman.py:229
↓ 1 callersMethodis_valid_public_key_static
(remote_public_key_str: int, prime: int)
ciphers/diffie_hellman.py:244
↓ 1 callersFunctionis_zero_vector
Check if vector is equal to (0, 0, 0) or not. Since the algorithm is very accurate, we will never get a zero vector, so we need to round
maths/points_are_collinear_3d.py:77
↓ 1 callersFunctionite_ternary_search
Iterative method of the ternary search algorithm. >>> test_list = [0, 1, 2, 8, 13, 17, 19, 32, 42] >>> ite_ternary_search(test_list, 3) -1
searches/ternary_search.py:62
↓ 1 callersFunctioniter_merge_sort
Return a sorted copy of the input list >>> iter_merge_sort([5, 9, 8, 7, 1, 2, 7]) [1, 2, 5, 7, 7, 8, 9] >>> iter_merge_sort([1])
sorts/iterative_merge_sort.py:29
↓ 1 callersFunctioniterate
Go through the number of iterations determined by the argument "steps". Be careful with high values (above 5) since the time to calculate inc
fractals/koch_snowflake.py:38
↓ 1 callersFunctioniteration_step
Loops through each pair of adjacent vectors. Each line between two adjacent vectors is divided into 4 segments by adding 3 additional vectors
fractals/koch_snowflake.py:53
↓ 1 callersFunctionjaccard_similarity
Finds the jaccard similarity between two sets. Essentially, its intersection over union. The alternative way to calculate this is to tak
maths/jaccard_similarity.py:17
↓ 1 callersFunctionjacobi_symbol
Calculate the Jacobi symbol. The Jacobi symbol is a generalization of the Legendre symbol, which can be used to simplify computations involvi
maths/solovay_strassen_primality_test.py:15
↓ 1 callersFunctionjaro_winkler
Jaro-Winkler distance is a string metric measuring an edit distance between two sequences. Output value is between 0.0 and 1.0. >>>
strings/jaro_winkler.py:4
↓ 1 callersFunctionjoint_probability_distribution
>>> joint_distribution = joint_probability_distribution( ... [1, 2], [-2, 5, 8], [0.7, 0.3], [0.3, 0.5, 0.2] ... ) >>> from math
maths/joint_probability_distribution.py:7
↓ 1 callersFunctionjosephus_recursive
Solve the Josephus problem for num_people and a step_size recursively. Args: num_people: A positive integer representing the number
maths/josephus_problem.py:18
↓ 1 callersFunctionjump_search
Python implementation of the jump search algorithm. Return the index if the `item` is found, otherwise return -1. Examples: >>> jump
searches/jump_search.py:20
↓ 1 callersFunctionjustify
(line: list, width: int, max_width: int)
strings/text_justification.py:35
↓ 1 callersFunctionkaratsuba
>>> karatsuba(15463, 23489) == 15463 * 23489 True >>> karatsuba(3, 9) == 3 * 9 True
maths/karatsuba.py:4
↓ 1 callersFunctionkmeans
Runs k-means on given data and initial set of centroids. maxiter: maximum number of iterations to run.(default=500) record_heterogeneity: (opt
machine_learning/k_means_clust.py:148
↓ 1 callersFunctionknapsack_recur
(capacity: int, counter: int)
knapsack/knapsack.py:41
↓ 1 callersFunctionknapsack_with_example_solution
Solves the integer weights knapsack problem returns one of the several possible optimal subsets. Parameters ---------- * `w`: i
dynamic_programming/knapsack.py:42
↓ 1 callersFunctionkosaraju
()
graphs/scc_kosaraju.py:24
↓ 1 callersFunctionkrishnamurthy
>>> krishnamurthy(145) True >>> krishnamurthy(240) False >>> krishnamurthy(1) True
maths/special_numbers/krishnamurthy_number.py:26
↓ 1 callersFunctionlanczos_iteration
Constructs the tridiagonal matrix and orthonormal basis vectors using the Lanczos method. Args: graph: The graph represented as a lis
graphs/lanczos_eigenvectors.py:71
↓ 1 callersFunctionlargest_divisible_subset
Algorithm to find the biggest subset in the given array such that for any 2 elements x and y in the subset, either x divides y or y divides x
dynamic_programming/largest_divisible_subset.py:4
↓ 1 callersFunctionlargest_product
(grid)
project_euler/problem_011/sol1.py:30
↓ 1 callersFunctionlargest_square_area_in_matrix_bottom_up
Function updates the largest_square_area, using bottom up approach. >>> largest_square_area_in_matrix_bottom_up(2, 2, [[1,1], [1,1]]) 2
matrix/largest_square_area_in_matrix.py:124
↓ 1 callersFunctionlcm
Least Common Multiple. Using the property that lcm(a, b) * greatest_common_divisor(a, b) = a*b >>> lcm(3, 15) 15 >>> lcm(1, 27)
project_euler/problem_005/sol2.py:21
↓ 1 callersFunctionleast_common_multiple_fast
Find the least common multiple of two numbers. https://en.wikipedia.org/wiki/Least_common_multiple#Using_the_greatest_common_divisor >>>
maths/least_common_multiple.py:25
↓ 1 callersFunctionleast_common_multiple_slow
Find the least common multiple of two numbers. Learn more: https://en.wikipedia.org/wiki/Least_common_multiple >>> least_common_multipl
maths/least_common_multiple.py:7
↓ 1 callersFunctionleast_divisible_repunit
Return the least value k such that the Repunit of length k is divisible by divisor. >>> least_divisible_repunit(7) 6 >>> least_divisi
project_euler/problem_129/sol1.py:17
↓ 1 callersMethodleft_child_idx
return the left child index if the left child exists. if not, return None.
data_structures/heap/heap.py:91
↓ 1 callersFunctionleft_rotate_32
Rotate the bits of a given int left by a given amount. Arguments: i {[int]} -- [given int] shift {[int]} -- [shift amount]
hashes/md5.py:253
↓ 1 callersMethodletter_to_numbers
Return the pair of numbers that represents the given letter in the polybius square >>> np.array_equal(PolybiusCipher().letter
ciphers/polybius.py:24
↓ 1 callersFunctionlevel_order
>>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = Tr
searches/binary_tree_traversal.py:108
↓ 1 callersFunctionlevel_order
Returns a list of nodes value from a whole binary tree in Level Order Traverse. Level Order traverse: Visit nodes of the tree level-by-leve
data_structures/binary_tree/binary_tree_traversals.py:96
↓ 1 callersFunctionlevel_order_actual
>>> root = TreeNode(1) >>> tree_node2 = TreeNode(2) >>> tree_node3 = TreeNode(3) >>> tree_node4 = TreeNode(4) >>> tree_node5 = Tr
searches/binary_tree_traversal.py:136
↓ 1 callersFunctionlevenshtein_distance
Implementation of the Levenshtein distance in Python. :param first_word: the first word to measure the difference. :param second_word: th
strings/levenshtein_distance.py:4
↓ 1 callersFunctionlevenshtein_distance_optimized
Compute the Levenshtein distance between two words (strings). The function is optimized for efficiency by modifying rows in place. :param
strings/levenshtein_distance.py:54
↓ 1 callersFunctionlexical_order
Generate numbers in lexical order from 1 to max_number. >>> " ".join(map(str, lexical_order(13))) '1 10 11 12 13 2 3 4 5 6 7 8 9' >>
data_structures/stacks/lexicographical_numbers.py:4
↓ 1 callersFunctionline_length
Approximates the arc length of a line segment by treating the curve as a sequence of linear lines and summing their lengths :param fnc: a
maths/line_length.py:7
↓ 1 callersFunctionlinear_discriminant_analysis
Linear Discriminant Analysis. For more details, see: https://en.wikipedia.org/wiki/Linear_discriminant_analysis. Parameters: * f
machine_learning/dimensionality_reduction.py:126
↓ 1 callersFunctionlinear_regression_prediction
First method: linear regression input : training data (date, total_user, total_event) in list of float output : list of total user predic
machine_learning/forecasting/run.py:23
↓ 1 callersFunctionlinear_search
A pure Python implementation of a linear search algorithm :param sequence: a collection with comparable items (sorting is not required for
searches/linear_search.py:12
↓ 1 callersMethodlink
( self, node1: DisjointSetTreeNode[T], node2: DisjointSetTreeNode[T] )
graphs/minimum_spanning_tree_kruskal2.py:33
↓ 1 callersFunctionlist_truncated_nums
Returns a list of all left and right truncated numbers of n >>> list_truncated_nums(927628) [927628, 27628, 92762, 7628, 9276, 628, 92
project_euler/problem_037/sol1.py:59
↓ 1 callersFunctionload_data
Returns a sample transaction dataset. >>> load_data() [['milk'], ['milk', 'butter'], ['milk', 'bread'], ['milk', 'bread', 'chips']]
machine_learning/apriori_algorithm.py:18
↓ 1 callersFunctionload_data
Load data from seaborn and split it into x and y points >>> pass # No doctests, function is for demo purposes only
machine_learning/local_weighted_learning/local_weighted_learning.py:130
↓ 1 callersFunctionload_dictionary
()
strings/detecting_english_programmatically.py:7
↓ 1 callersFunctionlocal_binary_value
It takes an image, an x and y coordinate, and returns the decimal value of the local binary patternof the pixel at that coordinate :
digital_image_processing/filters/local_binary_pattern.py:26
↓ 1 callersFunctionlocal_weight
Calculate the local weights at a given prediction point using the weight matrix for that point Args: point: x-value at which the
machine_learning/local_weighted_learning/local_weighted_learning.py:70
↓ 1 callersFunctionlocal_weight_regression
Calculate predictions for each point in the training data Args: x_train: ndarray of x-values for training y_train: ndarray o
machine_learning/local_weighted_learning/local_weighted_learning.py:102
↓ 1 callersFunctionlog_difference
This function returns the decimal value of a number multiplied with log(2) Since the problem is on powers of two, finding the powers of two w
project_euler/problem_686/sol1.py:20
↓ 1 callersFunctionlogistic_reg
(alpha, x, y, max_iterations=70000)
machine_learning/logistic_regression.py:112
↓ 1 callersFunctionlomuto_partition
Example: >>> lomuto_partition([1,5,7,6], 0, 3) 2
sorts/quick_sort_3_partition.py:75
↓ 1 callersFunctionlongest_common_subsequence
Finds the longest common subsequence between two strings. Also returns the The subsequence found Parameters ---------- x: str,
dynamic_programming/longest_common_subsequence.py:9
↓ 1 callersFunctionlongest_distance
(graph)
graphs/kahns_algorithm_long.py:2
↓ 1 callersFunctionlower_bound
Returns the index of the first element greater than or equal to the item. :param sorted_collection: The sorted list to search.
searches/binary_search.py:274
↓ 1 callersFunctionluhn_validation
Function to luhn algorithm validation for a given credit card number. >>> luhn_validation('4111111111111111') True >>> luhn_validatio
strings/credit_card_validator.py:21
↓ 1 callersFunctionmain
In this demonstration we're generating a sample data set from the sin function in numpy. We then train a decision tree on the data set and u
machine_learning/decision_tree.py:176
↓ 1 callersFunctionmain
Driver function to execute PCA and display results.
machine_learning/principle_component_analysis.py:64
↓ 1 callersFunctionmain
Driver function
machine_learning/linear_regression.py:128
↓ 1 callersFunctionmain
Fit a polynomial regression model to predict fuel efficiency using seaborn's mpg dataset >>> pass # Placeholder, function is only for
machine_learning/polynomial_regression.py:183
↓ 1 callersFunctionmain
Run t-SNE on the Iris dataset and display the first 5 embeddings. >>> main() # doctest: +ELLIPSIS t-SNE embedding (first 5 points):
machine_learning/t_stochastic_neighbour_embedding.py:149
↓ 1 callersFunctionmain
()
machine_learning/self_organizing_map.py:39
↓ 1 callersFunctionmain
The URL for this algorithm https://xgboost.readthedocs.io/en/stable/ California house price dataset is used to demonstrate the algorithm.
machine_learning/xgboost_regressor.py:40
↓ 1 callersFunctionmain
Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm.
machine_learning/xgboost_classifier.py:43
↓ 1 callersFunctionmain
This function starts execution phase
machine_learning/linear_discriminant_analysis.py:283
↓ 1 callersFunctionmain
()
strings/autocomplete_using_trie.py:57
↓ 1 callersFunctionmain
Get images list and annotations list from input dir. Update new images and annotations. Save images and annotations in output dir.
computer_vision/mosaic_augmentation.py:21
↓ 1 callersFunctionmain
Get images list and annotations list from input dir. Update new images and annotations. Save images and annotations in output dir.
computer_vision/flip_augmentation.py:20
↓ 1 callersFunctionmain
()
data_compression/peak_signal_to_noise_ratio.py:25
↓ 1 callersFunctionmain
Provides option 'string' or 'file' to take input and prints the calculated SHA1 hash. unittest.main() has been commented out because we proba
hashes/sha1.py:138
↓ 1 callersFunctionmain
Provides option 'string' or 'file' to take input and prints the calculated SHA-256 hash
hashes/sha256.py:209
↓ 1 callersFunctionmain
()
sorts/tim_sort.py:78
↓ 1 callersFunctionmain
()
sorts/odd_even_transposition_parallel.py:182
↓ 1 callersFunctionmain
()
sorts/pigeonhole_sort.py:42
↓ 1 callersFunctionmain
()
sorts/external_sort.py:139
↓ 1 callersFunctionmain
(args=None)
searches/tabu_search.py:253
↓ 1 callersFunctionmain
Call Extended Euclidean Algorithm.
maths/extended_euclidean_algorithm.py:74
↓ 1 callersFunctionmain
()
maths/average_median.py:34
↓ 1 callersFunctionmain
()
maths/quadratic_equations_complex_numbers.py:32
↓ 1 callersFunctionmain
Main function to test the trapezoidal rule. :a: Lower bound of integration :b: Upper bound of integration :steps: define number of st
maths/trapezoidal_rule.py:82
↓ 1 callersFunctionmain
()
maths/pi_generator.py:79
↓ 1 callersFunctionmain
Call Modular Exponential Function.
maths/modular_exponential.py:35
↓ 1 callersFunctionmain
Call Greatest Common Divisor function.
maths/greatest_common_divisor.py:63
↓ 1 callersFunctionmain
()
maths/karatsuba.py:27
↓ 1 callersFunctionmain
Print the Results of Various Volume Calculations.
maths/volume.py:543
↓ 1 callersFunctionmain
()
maths/matrix_exponentiation.py:122
↓ 1 callersFunctionmain
()
maths/collatz_sequence.py:59
↓ 1 callersFunctionmain
()
maths/entropy.py:111
↓ 1 callersFunctionmain
Request that user input an integer and tell them if it is Armstrong number.
maths/special_numbers/armstrong_numbers.py:85
↓ 1 callersFunctionmain
()
maths/numerical_analysis/newton_forward_interpolation.py:23
↓ 1 callersFunctionmain
()
maths/numerical_analysis/simpson_rule.py:73
↓ 1 callersFunctionmain
()
fractals/vicsek.py:69
↓ 1 callersFunctionmain
()
boolean_algebra/quine_mc_cluskey.py:139
↓ 1 callersFunctionmain
Main function to create and simplify a K-Map. >>> main() [0, 1] [1, 1] Simplified Expression: A'B + AB' + AB
boolean_algebra/karnaugh_map_simplification.py:32
↓ 1 callersFunctionmain
()
graphs/page_rank.py:52
↓ 1 callersFunctionmain
Main driver function for testing the implementation with doctests.
graphs/lanczos_eigenvectors.py:196
↓ 1 callersFunctionmain
Ant colony algorithm main function >>> main(cities=cities, ants_num=10, iterations_num=20, ... pheromone_evaporation=0.7, alpha=1.0,
graphs/ant_colony_optimization_algorithms.py:29
↓ 1 callersFunctionmain
Run example of bidirectional search algorithm. Examples: >>> main() # doctest: +NORMALIZE_WHITESPACE Path from 0 to 11: [0,
graphs/bidirectional_search.py:151
↓ 1 callersFunctionmain
()
graphs/eulerian_path_and_circuit_for_undirected_graph.py:52
← previousnext →1,501–1,600 of 3,909, ranked by callers