MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 1 callersFunctionsolution
Return the sum of N(n) for 1 <= n <= n_limit. >>> solution(1000,5) 222 >>> solution(1000,10) 249 >>> solution(10000,10)
project_euler/problem_174/sol1.py:24
↓ 1 callersFunctionsolution
Returns perimeter with maximum solutions. >>> solution(100) 90 >>> solution(200) 180 >>> solution(1000) 840
project_euler/problem_039/sol1.py:40
↓ 1 callersFunctionsolution
Returns the minimum difference of two pentagonal numbers P1 and P2 such that P1 + P2 is pentagonal and P2 - P1 is pentagonal. >>> solu
project_euler/problem_044/sol1.py:29
↓ 1 callersFunctionsolution
Returns >>> solution() 210
project_euler/problem_040/sol1.py:18
↓ 1 callersFunctionsolution
Returns the minimal path sum from the top left to the bottom right of the matrix. >>> solution() 427337
project_euler/problem_081/sol1.py:20
↓ 1 callersFunctionsolution
For any given exponent x >= 0, 1 <= n <= 2^x. This function returns how many Nim games are lost given that each Nim game has three heaps
project_euler/problem_301/sol1.py:36
↓ 1 callersFunctionsolution
Return the solution to the problem
project_euler/problem_033/sol1.py:60
↓ 1 callersFunctionsolution
Finds the amount of triangular words in the words file. >>> solution() 162
project_euler/problem_042/solution42.py:23
↓ 1 callersFunctionsolution
Calculate sum of |_ P_m _| for m from 2 to n. >>> solution(2) 1 >>> solution(3) 2 >>> solution(4) 4 >>> solution(5)
project_euler/problem_190/sol1.py:23
↓ 1 callersFunctionsolution
Finds the sum of all the positive integers which cannot be written as the sum of two abundant numbers as described by the statement above
project_euler/problem_023/sol1.py:22
↓ 1 callersFunctionsolution
Returns the next number which is triangular, pentagonal and hexagonal. >>> solution(144) 1533776805
project_euler/problem_045/sol1.py:44
↓ 1 callersFunctionsolution
Return the number of chains with a starting number below one million which contain exactly n non-repeating terms. >>> solution(10,1000)
project_euler/problem_074/sol1.py:98
↓ 1 callersFunctionsolution
Returns the number of numbers below number_limit that produce chains with exactly chain_length non repeating elements. >>> solution(10.0
project_euler/problem_074/sol2.py:72
↓ 1 callersFunctionsolution
Solve by explicitly counting the paths with dynamic programming. >>> solution(6) 924 >>> solution(2) 6 >>> solution(1) 2
project_euler/problem_015/sol2.py:10
↓ 1 callersFunctionsolution
Calculates sum of smallest number of multiplactions for each number up to and including n. >>> solution(1) 0 >>> solution(2)
project_euler/problem_122/sol1.py:62
↓ 1 callersFunctionsolution
Returns the number of different ways the number m can be written as a sum of at least two positive integers. >>> solution(100) 19056
project_euler/problem_076/sol1.py:19
↓ 1 callersFunctionsolution
Returns the first integer whose square is of the form 1_2_3_4_5_6_7_8_9_0
project_euler/problem_206/sol1.py:58
↓ 1 callersFunctionsolution
Returns the sum of the digits in the factorial of num >>> solution(100) 648 >>> solution(50) 216 >>> solution(10) 27 >>> s
project_euler/problem_020/sol1.py:31
↓ 1 callersFunctionsolution
Returns the sum of the digits in the factorial of num >>> solution(100) 648 >>> solution(50) 216 >>> solution(10) 27 >>> s
project_euler/problem_020/sol2.py:15
↓ 1 callersFunctionsolution
Returns the sum of the digits in the factorial of num >>> solution(100) 648 >>> solution(50) 216 >>> solution(10) 27 >>> s
project_euler/problem_020/sol4.py:13
↓ 1 callersFunctionsolution
Returns the sum of the digits in the factorial of num >>> solution(1000) 10539 >>> solution(200) 1404 >>> solution(100) 648
project_euler/problem_020/sol3.py:15
↓ 1 callersFunctionsolution
Returns for given minimum block length the least value of n for which the fill-count function first exceeds one million >>> solution(3)
project_euler/problem_115/sol1.py:30
↓ 1 callersFunctionsolution
Returns the number of ways a row of the given length can be filled >>> solution(7) 17
project_euler/problem_114/sol1.py:35
↓ 1 callersFunctionsolution
Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823
project_euler/problem_008/sol1.py:60
↓ 1 callersFunctionsolution
Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it. >>> solution("13978431290823
project_euler/problem_008/sol2.py:60
↓ 1 callersFunctionsolution
Find the thirteen adjacent digits in the 1000-digit number n that have the greatest product and returns it.
project_euler/problem_008/sol3.py:76
↓ 1 callersFunctionsolution
Returns the sum of all numbers whose sum of the factorials of all digits add up to the number itself. >>> solution() 40730
project_euler/problem_034/sol1.py:25
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 >>> solution(4) 3 >>> solution(10) 23 >>>
project_euler/problem_001/sol7.py:13
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 >>> solution(4) 3 >>> solution(10) 23 >>>
project_euler/problem_001/sol1.py:13
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 >>> solution(4) 3 >>> solution(10) 23 >>>
project_euler/problem_001/sol6.py:13
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 >>> solution(4) 3 >>> solution(10) 23 >>>
project_euler/problem_001/sol2.py:13
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. >>> solution(3) 0 >>> solution(4) 3 >>> solution(10) 23 >>>
project_euler/problem_001/sol4.py:13
↓ 1 callersFunctionsolution
Returns the sum of all the multiples of 3 or 5 below n. A straightforward pythonic solution using list comprehension. >>> solution(3)
project_euler/problem_001/sol5.py:13
↓ 1 callersFunctionsolution
This solution is based on the pattern that the successive numbers in the series follow: 0+3,+2,+1,+3,+1,+2,+3. Returns the sum of all the
project_euler/problem_001/sol3.py:13
↓ 1 callersFunctionsolution
This function calculates the power of two which is nth (n = number) smallest value of power of 2 such that the starting digits of the 2^p
project_euler/problem_686/sol1.py:46
↓ 1 callersFunctionsolution
Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> solution(50) 76 >>> solution(20) 31 >>> s
project_euler/problem_016/sol1.py:10
↓ 1 callersFunctionsolution
Returns the sum of the digits of the number 2^power. >>> solution(1000) 1366 >>> solution(50) 76 >>> solution(20) 31 >>>
project_euler/problem_016/sol2.py:10
↓ 1 callersFunctionsolution
Solves the problem for n_digits number of digits. >>> solution(2) 45 >>> solution(10) 21838806
project_euler/problem_164/sol1.py:51
↓ 1 callersFunctionsolution
Returns the value of 30th digit power sum. >>> solution(2) 512 >>> solution(5) 5832 >>> solution(10) 614656
project_euler/problem_119/sol1.py:29
↓ 1 callersFunctionsolution
Returns the sum of squarefrees for a given Pascal's Triangle of depth n. >>> solution(1) 1 >>> solution(8) 105 >>> solution(
project_euler/problem_203/sol1.py:100
↓ 1 callersFunctionsolution
Calculates and returns the answer to project euler problem 89. >>> solution("/numeralcleanup_test.txt") 16
project_euler/problem_089/sol1.py:118
↓ 1 callersFunctionsolution
Returns the minimal path sum in the matrix from the file, by starting in any cell in the left column and finishing in any cell in the right c
project_euler/problem_082/sol1.py:24
↓ 1 callersFunctionsolution
returns number of fractions containing a numerator with more digits than the denominator in the first n expansions. >>> solution(14)
project_euler/problem_057/sol1.py:23
↓ 1 callersFunctionsolution
Test the ciphertext against all possible 3-character keys, then narrow down the possibilities by filtering using common words until there's o
project_euler/problem_059/sol1.py:101
↓ 1 callersFunctionsolution
returns the values of n less than or equal to the limit have exactly ten distinct solutions. >>> solution(100) 0 >>> solution(100
project_euler/problem_135/sol1.py:23
↓ 1 callersFunctionsolution
Returns number of fractions lie between 1/3 and 1/2 in the sorted set of reduced proper fractions for d ≤ max_d >>> solution(4) 0
project_euler/problem_073/sol1.py:22
↓ 1 callersFunctionsolution
Returns the smallest positive number that is evenly divisible (divisible with no remainder) by all of the numbers from 1 to n. >>> solut
project_euler/problem_005/sol1.py:17
↓ 1 callersFunctionsolution
Returns the smallest positive number that is evenly divisible (divisible with no remainder) by all of the numbers from 1 to n. >>> solut
project_euler/problem_005/sol2.py:40
↓ 1 callersFunctionsolution
Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>
project_euler/problem_007/sol1.py:52
↓ 1 callersFunctionsolution
Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>
project_euler/problem_007/sol2.py:52
↓ 1 callersFunctionsolution
Returns the n-th prime number. >>> solution(6) 13 >>> solution(1) 2 >>> solution(3) 5 >>> solution(20) 71 >>
project_euler/problem_007/sol3.py:65
↓ 1 callersFunctionsolution
Returns the sum of all even fibonacci sequence elements that are lower or equal to n. >>> solution(10) 10 >>> solution(15) 1
project_euler/problem_002/sol1.py:19
↓ 1 callersFunctionsolution
Returns the sum of all even fibonacci sequence elements that are lower or equal to n. >>> solution(10) 10 >>> solution(15) 1
project_euler/problem_002/sol2.py:19
↓ 1 callersFunctionsolution
Returns the sum of all even fibonacci sequence elements that are lower or equal to n. >>> solution(10) 10 >>> solution(15) 1
project_euler/problem_002/sol4.py:22
↓ 1 callersFunctionsolution
Returns the sum of all even fibonacci sequence elements that are lower or equal to n. >>> solution(10) 10 >>> solution(15) 1
project_euler/problem_002/sol5.py:19
↓ 1 callersFunctionsolution
Returns the sum of all even fibonacci sequence elements that are lower or equal to n. >>> solution(10) 10 >>> solution(15) 1
project_euler/problem_002/sol3.py:19
↓ 1 callersFunctionsolution_times
()
maths/triplet_sum.py:69
↓ 1 callersFunctionsolve
This function creates a state space tree and calls the safe function until it receives a False Boolean and terminates that branch and backtra
backtracking/n_queens.py:63
↓ 1 callersFunctionsolve
Finds the max sum for array `arr` starting with row index `row`, and with columns included in `cols`. `cache` is used for caching intermediat
project_euler/problem_345/sol1.py:67
↓ 1 callersFunctionsolve
Solve the linear system of equations Ax = b (A = "matrix", b = "vector") for x using Gaussian elimination and back substitution. We assume th
project_euler/problem_101/sol1.py:52
↓ 1 callersFunctionsolve
Checks if nums can have a sum equal to goal, given that length of nums does not exceed depth. >>> solve([1], 2, 2) True >>> solv
project_euler/problem_122/sol1.py:40
↓ 1 callersFunctionsolve
Solve for remaining 'digit' digits, with previous 'prev1' digit, and previous-previous 'prev2' digit, total sum of 'sum_max'. Pass around
project_euler/problem_164/sol1.py:13
↓ 1 callersFunctionsolve_all
Attempt to solve a sequence of grids. Report results. When showif is a number of seconds, display puzzles that take longer. When showif i
data_structures/arrays/sudoku_solver.py:169
↓ 1 callersFunctionsolve_crossword
Solve the crossword puzzle using backtracking. >>> puzzle = [ ... ['', '', '', ''], ... ['', '', '', ''], ... ['', '
backtracking/crossword_puzzle_solver.py:82
↓ 1 callersFunctionsolve_linear_system
Solve a linear system of equations using Gaussian elimination with partial pivoting Args: - `matrix`: Coefficient matrix with the last
linear_algebra/src/gaussian_elimination_pivoting.py:4
↓ 1 callersFunctionsolved
A puzzle is solved if each unit is a permutation of the digits 1 to 9.
data_structures/arrays/sudoku_solver.py:196
↓ 1 callersFunctionsolver
Returns the maximum sum by making recursive calls >>> t1 = TreeNode(1) >>> print(solver(t1)) 1
data_structures/binary_tree/maximum_sum_bst.py:49
↓ 1 callersFunctionsome
Return some element of seq that is true.
data_structures/arrays/sudoku_solver.py:148
↓ 1 callersFunctionsortlist_2d
>>> sortlist_2d([[9, 10], [1, 6], [7, 8], [2, 3], [4, 5]]) [[1, 6], [2, 3], [4, 5], [7, 8], [9, 10]]
sorts/merge_insertion_sort.py:52
↓ 1 callersFunctionspiral_print_clockwise
>>> spiral_print_clockwise([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) 1 2 3 4 8 12 11 10 9 5 6
matrix/spiral_print.py:30
↓ 1 callersFunctionsplit_and_add
Split number digits and add them.
project_euler/problem_020/sol1.py:21
↓ 1 callersMethodsplit_blocks
Returns a list of bytestrings each of length 64
hashes/sha1.py:69
↓ 1 callersFunctionsquare_zero_matrix
returns a square zero-matrix of dimension NxN
linear_algebra/src/lib.py:427
↓ 1 callersFunctionstock_price
>>> stock_price("EEEE") 'No <fin-streamer> tag with the specified data-testid attribute found.' >>> isinstance(float(stock_price("GOOG"))
web_programming/current_stock_price.py:23
↓ 1 callersFunctionstooge
(arr: list[int], i: int, h: int)
sorts/stooge_sort.py:14
↓ 1 callersFunctionstooge_sort
Examples: >>> stooge_sort([18.1, 0, -7.1, -1, 2, 2]) [-7.1, -1, 0, 2, 2, 18.1] >>> stooge_sort([]) []
sorts/stooge_sort.py:1
↓ 1 callersFunctionstr_eval
Returns product of digits in given string n >>> str_eval("987654321") 362880 >>> str_eval("22222222") 256
project_euler/problem_008/sol3.py:60
↓ 1 callersFunctionstraight_line_depreciation
Calculate the depreciation expenses over the given period :param useful_years: Number of years the asset will be used :param purchase_val
financial/straight_line_depreciation.py:32
↓ 1 callersFunctionstrassen
>>> strassen([[2,1,3],[3,4,6],[1,4,2],[7,6,7]], [[4,2,3,4],[2,1,1,1],[8,6,4,2]]) [[34, 23, 19, 15], [68, 46, 37, 28], [28, 18, 15, 12], [96,
divide_and_conquer/strassen_matrix_multiplication.py:107
↓ 1 callersMethodstretch
(self, input_image)
digital_image_processing/histogram_equalization/histogram_stretch.py:27
↓ 1 callersFunctionstrictly_diagonally_dominant
>>> table = np.array([[4, 1, 1, 2], [1, 5, 2, -6], [1, 2, 4, -4]]) >>> strictly_diagonally_dominant(table) True >>> table = np.array
linear_algebra/jacobi_iteration_method.py:169
↓ 1 callersFunctionstrong_connect
(v: int, index: int, components: list[list[int]])
graphs/tarjans_scc.py:45
↓ 1 callersFunctionsubset_combinations
Compute n-element combinations from a given list using dynamic programming. Args: * `elements`: The list of elements from which comb
dynamic_programming/subset_generation.py:1
↓ 1 callersFunctionsudoku
Takes a partially filled-in grid and attempts to assign values to all unassigned locations in such a way to meet the requirements for Sud
backtracking/sudoku.py:75
↓ 1 callersFunctionsum_digit_factorials
Return the sum of the factorial of the digits of n. >>> sum_digit_factorials(145) 145 >>> sum_digit_factorials(45361) 871 >>>
project_euler/problem_074/sol1.py:56
↓ 1 callersFunctionsum_digits
Returns the sum of every digit in num. >>> sum_digits(1) 1 >>> sum_digits(12345) 15 >>> sum_digits(999001) 28
project_euler/problem_065/sol1.py:56
↓ 1 callersFunctionsum_of_digit_factorial
Returns the sum of the factorial of digits in n >>> sum_of_digit_factorial(15) 121 >>> sum_of_digit_factorial(0) 1
project_euler/problem_034/sol1.py:14
↓ 1 callersFunctionsum_of_digits
Find the sum of digits of a number. >>> sum_of_digits(12345) 15 >>> sum_of_digits(123) 6 >>> sum_of_digits(-123) 6 >>
maths/sum_of_digits.py:1
↓ 1 callersFunctionsum_of_harmonic_progression
https://en.wikipedia.org/wiki/Harmonic_progression_(mathematics) Find the sum of n terms in an harmonic progression. The calculation starts
maths/sum_of_harmonic_series.py:1
↓ 1 callersFunctionsum_of_series
Find the sum of n terms in an arithmetic progression. >>> sum_of_series(1, 1, 10) 55.0 >>> sum_of_series(1, 10, 100) 49600.0
maths/sum_of_arithmetic_series.py:2
↓ 1 callersFunctionsum_of_square_error
Return sum of square error for error calculation :param data_x : contains our dataset :param data_y : contains the output (result vector
machine_learning/linear_regression.py:70
↓ 1 callersFunctionsum_reverse
Returns the sum of n and reverse of n. >>> sum_reverse(123) 444 >>> sum_reverse(3478) 12221 >>> sum_reverse(12) 33
project_euler/problem_055/sol1.py:43
↓ 1 callersFunctionsummarize_book
Given Open Library book data, return a summary as a Python dict.
web_programming/search_books_by_isbn.py:40
↓ 1 callersMethodsummary
(self)
neural_network/back_propagation_neural_network.py:120
↓ 1 callersFunctionsummation_of_cost_derivative
Calculates the sum of cost function derivative :param index: index wrt derivative is being calculated :param end: value where summation e
machine_learning/gradient_descent.py:76
↓ 1 callersFunctionsupport_vector_regressor
Third method: Support vector regressor svr is quite the same with svm(support vector machine) it uses the same principles as the SVM for
machine_learning/forecasting/run.py:62
↓ 1 callersFunctionsuppress_non_maximum
Non-maximum suppression. If the edge strength of the current pixel is the largest compared to the other pixels in the mask with the same dire
digital_image_processing/edge_detection/canny.py:21
↓ 1 callersFunctionsurface_area_cone
Calculate the Surface Area of a Cone. Wikipedia reference: https://en.wikipedia.org/wiki/Cone Formula: pi * r * (r + (h ** 2 + r ** 2)
maths/area.py:106
↓ 1 callersFunctionsurface_area_conical_frustum
Calculate the Surface Area of a Conical Frustum. >>> surface_area_conical_frustum(1, 2, 3) 45.511728065337266 >>> surface_area_
maths/area.py:138
↓ 1 callersFunctionsurface_area_cube
Calculate the Surface Area of a Cube. >>> surface_area_cube(1) 6 >>> surface_area_cube(1.6) 15.360000000000003 >>> su
maths/area.py:9
← previousnext →2,101–2,200 of 3,909, ranked by callers