MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 1 callersMethodremove_node_pointers
(node: Node)
data_structures/linked_list/doubly_linked_list_two.py:152
↓ 1 callersFunctionremove_prefix
Removes size prefix, that compressed file should have Returns the result
data_compression/lempel_ziv_decompress.py:84
↓ 1 callersFunctionremove_word
Remove a word from the given position. >>> puzzle = [ ... ['w', '', '', ''], ... ['o', '', '', ''], ... ['r', '', ''
backtracking/crossword_puzzle_solver.py:59
↓ 1 callersFunctionreset
()
hashes/chaos_machine.py:75
↓ 1 callersMethodreset_reproduction_time
>>> e = Entity(True, coords=(0, 0)) >>> e.reset_reproduction_time() >>> e.remaining_reproduction_time == PREY_REPRODUCTION_TI
cellular_automata/wa_tor.py:62
↓ 1 callersMethodretrace_bidirectional_path
(self, fwd_node: Node, bwd_node: Node)
graphs/bidirectional_breadth_first_search.py:157
↓ 1 callersMethodretrace_bidirectional_path
( self, fwd_node: Node, bwd_node: Node )
graphs/bidirectional_a_star.py:232
↓ 1 callersMethodretrace_path
Retrace the path from parents to parents until start node
graphs/greedy_best_first.py:168
↓ 1 callersFunctionretroactive_resolution
This function performs a retroactive linear system resolution for triangular matrix Examples: 1. * 2x1 + 2x2 - 1x3 =
linear_algebra/gaussian_elimination.py:11
↓ 1 callersFunctionreverse_bwt
:param bwt_string: The string returned from bwt algorithm execution :param idx_original_string: A 0-based index of the string that was used t
data_compression/burrows_wheeler.py:93
↓ 1 callersFunctionreverse_floyd
Print the lower half of a diamond pattern with '*' characters. Args: n (int): Size of the pattern. Examples: >>>
other/magicdiamondpattern.py:30
↓ 1 callersFunctionreverse_inorder
Reverse in-order traversal visits right subtree, root node, left subtree. >>> list(reverse_inorder(make_tree())) [3, 1, 5, 2, 4]
data_structures/binary_tree/binary_tree_traversals.py:72
↓ 1 callersMethodreverse_k_nodes
reverse nodes within groups of size k >>> ll = LinkedList([1, 2, 3, 4, 5]) >>> ll.reverse_k_nodes(2) >>> tuple(ll)
data_structures/linked_list/reverse_k_group.py:76
↓ 1 callersFunctionreverse_letters
Reverse all words that are longer than the given length of characters in a sentence. If ``length`` is not specified, it defaults to 0. >
strings/reverse_letters.py:1
↓ 1 callersFunctionreversible_numbers
Count the number of reversible numbers of given length. Iterate over possible digits considering parity of current sum remainder. >>> rev
project_euler/problem_145/sol1.py:96
↓ 1 callersFunctionrevise_centroids
(data, k, cluster_assignment)
machine_learning/k_means_clust.py:95
↓ 1 callersFunctionrgb_to_gray
Return gray image from rgb image >>> rgb_to_gray(np.array([[[127, 255, 0]]])) array([[187.6453]]) >>> rgb_to_gray(np.array([[[0
digital_image_processing/morphological_operations/erosion_operation.py:7
↓ 1 callersFunctionrgb_to_gray
Return gray image from rgb image >>> rgb_to_gray(np.array([[[127, 255, 0]]])) array([[187.6453]]) >>> rgb_to_gray(np.array([[[0,
digital_image_processing/morphological_operations/dilation_operation.py:7
↓ 1 callersMethodright_child_idx
return the right child index if the right child exists. if not, return None.
data_structures/heap/heap.py:101
↓ 1 callersFunctionrms_speed_of_molecule
>>> rms_speed_of_molecule(100, 2) 35.315279554323226 >>> rms_speed_of_molecule(273, 12) 23.821458421977443
physics/rms_speed_of_molecule.py:26
↓ 1 callersFunctionrotate
Standard rotation of a 2D vector with a rotation matrix (see https://en.wikipedia.org/wiki/Rotation_matrix ) >>> rotate(np.array([1, 0]),
fractals/koch_snowflake.py:77
↓ 1 callersFunctionrotate
rotate a point around a certain axis with a certain angle angle can be any integer between 1, 360 and axis can be any one of 'x', 'y', 'z
graphics/vector3_for_2d_rendering.py:38
↓ 1 callersFunctionrotate_180
>>> rotate_180(make_matrix()) [[16, 15, 14, 13], [12, 11, 10, 9], [8, 7, 6, 5], [4, 3, 2, 1]] >>> rotate_180(make_matrix()) == reverse_co
matrix/rotate_matrix.py:40
↓ 1 callersFunctionrotate_270
>>> rotate_270(make_matrix()) [[13, 9, 5, 1], [14, 10, 6, 2], [15, 11, 7, 3], [16, 12, 8, 4]] >>> rotate_270(make_matrix()) == transpose(
matrix/rotate_matrix.py:52
↓ 1 callersFunctionrotate_90
>>> rotate_90(make_matrix()) [[4, 8, 12, 16], [3, 7, 11, 15], [2, 6, 10, 14], [1, 5, 9, 13]] >>> rotate_90(make_matrix()) == transpose(re
matrix/rotate_matrix.py:28
↓ 1 callersFunctionrotate_array
Rotates a list to the right by steps positions. Parameters: arr (List[int]): The list of integers to rotate. steps (int): Number of
data_structures/arrays/rotate_array.py:1
↓ 1 callersFunctionrotate_to_the_right
Rotate a linked list to the right by places times. Parameters: head: The head of the linked list. places: The number of plac
data_structures/linked_list/rotate_to_the_right.py:70
↓ 1 callersFunctionrotation
>>> rotation(45) # doctest: +NORMALIZE_WHITESPACE [[0.5253219888177297, -0.8509035245341184], [0.8509035245341184, 0.5253219888177297]]
linear_algebra/src/transformations_2d.py:29
↓ 1 callersMethodround_robin
RR(Round Robin) RR will be applied to MLFQ's all queues except last queue All processes can't use CPU for time more than time
scheduling/multi_level_feedback_queue.py:189
↓ 1 callersFunctionrun
This function runs the rules of game through all points, and changes their status accordingly.(in the same canvas) @Args: -- canv
cellular_automata/game_of_life.py:55
↓ 1 callersFunctionrun
Runs core process to find problem solution. >>> run(3) [644, 645, 646]
project_euler/problem_047/sol1.py:72
↓ 1 callersFunctionrun_gradient_descent
()
machine_learning/gradient_descent.py:105
↓ 1 callersFunctionrun_linear_regression
Implement Linear regression over the dataset :param data_x : contains our dataset :param data_y : contains the output (result vector) :r
machine_learning/linear_regression.py:91
↓ 1 callersFunctionrun_maze
This method is recursive starting from (i, j) and going in one of four directions: up, down, left, right. If a path is found to destinati
backtracking/rat_in_maze.py:139
↓ 1 callersFunctionrun_steep_gradient_descent
Run steep gradient descent and updates the Feature vector accordingly_ :param data_x : contains the dataset :param data_y : contains the o
machine_learning/linear_regression.py:43
↓ 1 callersFunctionrunning_key_decrypt
Decrypts the ciphertext using the Running Key Cipher. :param key: The running key (long piece of text). :param ciphertext: The ciphertex
ciphers/running_key_cipher.py:29
↓ 1 callersFunctionrunning_key_encrypt
Encrypts the plaintext using the Running Key Cipher. :param key: The running key (long piece of text). :param plaintext: The plaintext t
ciphers/running_key_cipher.py:6
↓ 1 callersFunctionsarimax_predictor
second method: Sarimax sarimax is a statistic method which using previous input and learn its pattern to predict future data input :
machine_learning/forecasting/run.py:40
↓ 1 callersFunctionsave_apod
(api_key: str, path: str = ".")
web_programming/nasa_data.py:20
↓ 1 callersFunctionsave_image
Saves the image of anime character
web_programming/random_anime_character.py:20
↓ 1 callersFunctionscalar_multiply
>>> scalar_multiply([[1,2],[3,4]],5) [[5, 10], [15, 20]] >>> scalar_multiply([[1.4,2.3],[3,4]],5) [[7.0, 11.5], [15, 20]]
matrix/matrix_operation.py:50
↓ 1 callersFunctionscaling
>>> scaling(5) [[5.0, 0.0], [0.0, 5.0]]
linear_algebra/src/transformations_2d.py:20
↓ 1 callersFunctionsearch
Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched :param key: the key to be s
searches/double_linear_search_recursion.py:1
↓ 1 callersFunctionsearch
Search for a path on a grid avoiding obstacles. >>> grid = [[0, 1, 0, 0, 0, 0], ... [0, 1, 0, 0, 0, 0], ... [0, 1, 0,
graphs/a_star.py:12
↓ 1 callersFunctionsearch
Using depth-first search and propagation, try all possible values.
data_structures/arrays/sudoku_solver.py:156
↓ 1 callersFunctionsearch
Recursively searches for the nearest neighbor in the KD-Tree. Args: node: The current node in the KD-Tree. d
data_structures/kd_tree/nearest_neighbour_search.py:34
↓ 1 callersFunctionsearch
function to search a number in a list using Binary Search. >>> search(3, [1, 2, 3]) True >>> search(4, [1, 2, 3]) False >>> s
project_euler/problem_049/sol1.py:71
↓ 1 callersMethodsearch
Search for the path, if a path is not found, only the starting position is returned
graphs/greedy_best_first.py:119
↓ 1 callersMethodsearch
>>> tree = BinarySearchTree().insert(10, 20, 30, 40, 50) >>> tree.search(10) {'10': (None, {'20': (None, {'30': (None, {'40':
data_structures/binary_tree/binary_search_tree.py:200
↓ 1 callersMethodsearch
Search through the tree for label, returning its node if it's found, and None otherwise. This method is guaranteed to run in O(log(n
data_structures/binary_tree/red_black_tree.py:350
↓ 1 callersFunctionsearch_anime_episode_list
[summary] Take an url and return list of episodes after scraping the site for an url. >>> type(search_anime_episode_list("/anime/kim
web_programming/fetch_anime_and_play.py:72
↓ 1 callersFunctionsearch_in_a_sorted_matrix
>>> search_in_a_sorted_matrix( ... [[2, 5, 7], [4, 8, 13], [9, 11, 15], [12, 17, 20]], 3, 3, 5) Key 5 found at row- 1 column- 2 >
matrix/searching_in_sorted_matrix.py:4
↓ 1 callersFunctionsearch_scraper
[summary] Take an url and return list of anime after scraping the site. >>> type(search_scraper("demon_slayer")) <class 'list'>
web_programming/fetch_anime_and_play.py:17
↓ 1 callersFunctionsecant_method
>>> secant_method(1, 3, 2) 0.2139409276214589
maths/numerical_analysis/secant_method.py:17
↓ 1 callersFunctionsegment_image
Performs image segmentation based on intensity thresholds. Args: image: Input grayscale image as a 2D array. thresholds
computer_vision/intensity_based_segmentation.py:9
↓ 1 callersFunctionsegments_intersect
Return True if line segment p1p2 intersects line segment p3p4. Uses the CLRS cross-product / orientation method. Handles both the general ca
geometry/segment_intersection.py:66
↓ 1 callersFunctionselect
Select the second parent and generate new population >>> random.seed(42) >>> parent_1 = ("123456", 8.0) >>> population_score = [("ab
genetic_algorithm/basic_string.py:62
↓ 1 callersFunctionselection
>>> selection([[1]],['0.00.01.5']) ['0.00.01.5'] >>> selection([[1]],['0.00.01.5']) ['0.00.01.5']
boolean_algebra/quine_mc_cluskey.py:81
↓ 1 callersFunctionselection_sort
Sorts a list in ascending order using the selection sort algorithm. :param collection: A list of integers to be sorted. :return: The sor
sorts/selection_sort.py:1
↓ 1 callersFunctionsemi_perfect
>>> semi_perfect(0) True >>> semi_perfect(1) True >>> semi_perfect(12) True >>> semi_perfect(13) False # >>> sem
maths/special_numbers/weird_number.py:51
↓ 1 callersFunctionsend_slack_message
(message_body: str, slack_url: str)
web_programming/slack_message.py:13
↓ 1 callersFunctionsentinel_linear_search
Pure implementation of sentinel linear search algorithm in Python :param sequence: some sequence with comparable items :param target: item va
searches/sentinel_linear_search.py:14
↓ 1 callersFunctionset_color
(rgb: str)
fractals/vicsek.py:53
↓ 1 callersMethodset_data
(self, data: Any)
data_structures/binary_tree/avl_tree.py:62
↓ 1 callersMethodset_fail_transitions
(self)
strings/aho_corasick.py:42
↓ 1 callersMethodset_head
(self, node: Node)
data_structures/linked_list/doubly_linked_list_two.py:78
↓ 1 callersMethodset_maximum_flow_algorithm
(self, algorithm)
graphs/edmonds_karp_multiple_source_and_sink.py:56
↓ 1 callersMethodset_planet
Ease of access for testing >>> wt = WaTor(WIDTH, HEIGHT) >>> planet = [ ... [None, None, None], ... [None, E
cellular_automata/wa_tor.py:132
↓ 1 callersFunctionshell_sort
Pure implementation of shell sort algorithm in Python :param collection: Some mutable ordered collection with heterogeneous comparable items
sorts/shell_sort.py:6
↓ 1 callersMethodsherman_morrison
<method Matrix.sherman_morrison> Apply Sherman-Morrison formula in O(n^2). To learn this formula, please look this: h
matrix/sherman_morrison.py:203
↓ 1 callersFunctionshow_bits
>>> print(show_bits(0, 0xFFFF)) 0: 00000000 65535: 1111111111111111
bit_manipulation/swap_all_odd_and_even_bits.py:1
↓ 1 callersMethodshow_data
(self)
data_structures/binary_tree/segment_tree.py:99
↓ 1 callersMethodshow_distances
Show the distances from src to all other nodes in a graph Examples: >>> graph_test = Graph(1) >>> graph_test.show_di
graphs/dijkstra_algorithm.py:380
↓ 1 callersMethodshow_graph
Show the graph: u -> v(w) Examples: >>> graph_test = Graph(1) >>> graph_test.add_edge(1, 2, 1) >>> graph_tes
graphs/dijkstra_algorithm.py:258
↓ 1 callersMethodshow_image
(self)
digital_image_processing/histogram_equalization/histogram_stretch.py:52
↓ 1 callersMethodshow_path
Shows the shortest path from src to dest. WARNING: Use it *after* calling dijkstra. Examples: >>> graph_test = Graph
graphs/dijkstra_algorithm.py:394
↓ 1 callersFunctionshuffled
Return a randomly shuffled copy of the input sequence.
data_structures/arrays/sudoku_solver.py:229
↓ 1 callersFunctionsieve
Segmented Sieve. Examples: >>> sieve(8) [2, 3, 5, 7] >>> sieve(27) [2, 3, 5, 7, 11, 13, 17, 19, 23] >>> siev
maths/segmented_sieve.py:6
↓ 1 callersFunctionsieve
Returns a prime number generator using sieve method. >>> type(sieve()) <class 'generator'> >>> primes = sieve() >>> next(primes)
project_euler/problem_123/sol1.py:46
↓ 1 callersFunctionsigmoid
Mathematical function sigmoid takes a vector x of K real numbers as input and returns 1/ (1 + e^-x). https://en.wikipedia.org/wiki/Sigmoi
neural_network/activation_functions/gaussian_error_linear_unit.py:16
↓ 1 callersFunctionsimple_fibonacci_time
()
maths/matrix_exponentiation.py:109
↓ 1 callersFunctionsimple_moving_average
Calculate the simple moving average (SMA) for some given time series data. :param data: A list of numerical data points. :param window_s
financial/simple_moving_average.py:13
↓ 1 callersFunctionsimplify
>>> simplify([[1, 2, 3], [4, 5, 6]]) [[1.0, 2.0, 3.0], [0.0, 0.75, 1.5]] >>> simplify([[5, 2, 5], [5, 1, 10]]) [[1.0, 0.4, 1.0],
maths/simultaneous_linear_equation_solver.py:12
↓ 1 callersFunctionslow_calculate_prime_numbers
Returns prime numbers below max_number. See: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes >>> slow_calculate_prime_numbers(10)
project_euler/problem_187/sol1.py:17
↓ 1 callersFunctionsmallest_range
Find the smallest range from each list in nums. Uses min heap for efficiency. The range includes at least one number from each list. Ar
greedy_methods/smallest_range.py:10
↓ 1 callersFunctionsmith_waterman
Perform the Smith-Waterman local sequence alignment algorithm. Returns a 2D list representing the score matrix. Each value in the matrix
dynamic_programming/smith_waterman.py:39
↓ 1 callersFunctionsock_merchant
>>> sock_merchant([10, 20, 20, 10, 10, 30, 50, 10, 20]) 3 >>> sock_merchant([1, 1, 3, 3]) 2
maths/sock_merchant.py:4
↓ 1 callersFunctionsoftmax
Implements the softmax function Parameters: vector (np.array,list,tuple): A numpy array of shape (1,n) consisting of real v
maths/softmax.py:16
↓ 1 callersFunctionsoftplus
Implements the Softplus activation function. Parameters: vector (np.ndarray): The input array for the Softplus activation. Retu
neural_network/activation_functions/softplus.py:12
↓ 1 callersFunctionsolution
returns n-th term of sequence >>> solution(10) 62 >>> solution(10**6) 31054319 >>> solution(10**15) 73597483551591773
project_euler/problem_551/sol1.py:170
↓ 1 callersFunctionsolution
Returns probability that Pyramidal Peter beats Cubic Colin rounded to seven decimal places in the form 0.abcdefg >>> solution() 0.57
project_euler/problem_205/sol1.py:41
↓ 1 callersFunctionsolution
Returns the sum of all numbers less than 1e8 that are both palindromic and can be written as the sum of consecutive squares.
project_euler/problem_125/sol1.py:35
↓ 1 callersFunctionsolution
Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. >>> solution() '9110846700'
project_euler/problem_048/sol1.py:11
↓ 1 callersFunctionsolution
Returns the number of blue discs for the first arrangement to contain over min_total discs in total >>> solution(2) 3 >>> solut
project_euler/problem_100/sol1.py:16
↓ 1 callersFunctionsolution
Returns least value of n for which the concave triangle occupies less than fraction of the L-section >>> solution(1 / 10) 15
project_euler/problem_587/sol1.py:75
↓ 1 callersFunctionsolution
To evaluate the solution, use solution() >>> solution(3) 120 >>> solution(6) 18720 >>> solution(7) 68720
project_euler/problem_145/sol1.py:116
↓ 1 callersFunctionsolution
Return the smallest integer that can be written as the sum of primes in over m unique ways. >>> solution(4) 10 >>> solution(500)
project_euler/problem_077/sol1.py:64
↓ 1 callersFunctionsolution
Returns the index of the first term in the Fibonacci sequence to contain n digits. >>> solution(1000) 4782 >>> solution(100)
project_euler/problem_025/sol1.py:83
↓ 1 callersFunctionsolution
Returns the index of the first term in the Fibonacci sequence to contain n digits. >>> solution(1000) 4782 >>> solution(100) 476
project_euler/problem_025/sol2.py:52
↓ 1 callersFunctionsolution
Returns the index of the first term in the Fibonacci sequence to contain n digits. >>> solution(1000) 4782 >>> solution(100) 476
project_euler/problem_025/sol3.py:28
← previousnext →1,901–2,000 of 3,909, ranked by callers