MCPcopy Create free account

hub / github.com/TheAlgorithms/Python / functions

Functions3,909 in github.com/TheAlgorithms/Python

↓ 1 callersFunctionvalidate
To optimize the approach, we will rule out the numbers above 1000, whose first or last three digits are not prime >>> validate(74679)
project_euler/problem_037/sol1.py:77
↓ 1 callersFunctionvalidate_adjacency_list
Validates the adjacency list format for the graph. Args: graph: A list of lists where each sublist contains the neighbors of a node.
graphs/lanczos_eigenvectors.py:32
↓ 1 callersFunctionvalidate_initial_digits
Function to validate initial digits of a given credit card number. >>> valid = "4111111111111111 41111111111111 34 35 37 412345 523456 634567
strings/credit_card_validator.py:8
↓ 1 callersFunctionvalidate_matrix_content
Validates that the number of elements in the matrix matches the given size. >>> validate_matrix_content(['aaaa', 'aaaa', 'aaaa', 'aaaa'], 3)
matrix/matrix_based_game.py:64
↓ 1 callersFunctionvalidate_matrix_size
>>> validate_matrix_size(-1) Traceback (most recent call last): ... ValueError: Matrix size must be a positive integer.
matrix/matrix_based_game.py:53
↓ 1 callersFunctionvalidate_moves
>>> validate_moves([(1, 2), (-1, 0)], 3) Traceback (most recent call last): ... ValueError: Move is out of bounds for a matrix.
matrix/matrix_based_game.py:92
↓ 1 callersFunctionvernam_decrypt
>>> vernam_decrypt("RIJVS","KEY") 'HELLO'
ciphers/vernam_cipher.py:15
↓ 1 callersFunctionvernam_encrypt
>>> vernam_encrypt("HELLO","KEY") 'RIJVS'
ciphers/vernam_cipher.py:1
↓ 1 callersFunctionvisualise_word_search
Graphically displays the word search in the terminal. >>> ws = WordSearch(WORDS, 5, 5) >>> ws.insert_north("cat", [4], [4]) >>> visu
other/word_search.py:347
↓ 1 callersFunctionvol_circular_cylinder
r""" | Calculate the Volume of a Circular Cylinder. | Wikipedia reference: https://en.wikipedia.org/wiki/Cylinder :return: :math:`\pi \cd
maths/volume.py:372
↓ 1 callersFunctionvol_cone
r""" | Calculate the Volume of a Cone. | Wikipedia reference: https://en.wikipedia.org/wiki/Cone :return: :math:`\frac{1}{3} \cdot area\_
maths/volume.py:205
↓ 1 callersFunctionvol_conical_frustum
| Calculate the Volume of a Conical Frustum. | Wikipedia reference: https://en.wikipedia.org/wiki/Frustum >>> vol_conical_frustum(45, 7,
maths/volume.py:443
↓ 1 callersFunctionvol_cube
Calculate the Volume of a Cube. >>> vol_cube(1) 1.0 >>> vol_cube(3) 27.0 >>> vol_cube(0) 0.0 >>> vol_cube(1.6) 4
maths/volume.py:13
↓ 1 callersFunctionvol_cuboid
Calculate the Volume of a Cuboid. :return: multiple of `width`, `length` and `height` >>> vol_cuboid(1, 1, 1) 1.0 >>> vol_cuboi
maths/volume.py:173
↓ 1 callersFunctionvol_hemisphere
r""" | Calculate the volume of a hemisphere | Wikipedia reference: https://en.wikipedia.org/wiki/Hemisphere | Other references: https://ww
maths/volume.py:345
↓ 1 callersFunctionvol_hollow_circular_cylinder
Calculate the Volume of a Hollow Circular Cylinder. >>> vol_hollow_circular_cylinder(1, 2, 3) 28.274333882308138 >>> vol_hollow_circ
maths/volume.py:402
↓ 1 callersFunctionvol_icosahedron
| Calculate the Volume of an Icosahedron. | Wikipedia reference: https://en.wikipedia.org/wiki/Regular_icosahedron >>> from math import
maths/volume.py:513
↓ 1 callersFunctionvol_prism
r""" | Calculate the Volume of a Prism. | Wikipedia reference: https://en.wikipedia.org/wiki/Prism_(geometry) :return: :math:`V = B \cdot
maths/volume.py:261
↓ 1 callersFunctionvol_pyramid
r""" | Calculate the Volume of a Pyramid. | Wikipedia reference: https://en.wikipedia.org/wiki/Pyramid_(geometry) :return: :math:`\frac{1
maths/volume.py:290
↓ 1 callersFunctionvol_right_circ_cone
r""" | Calculate the Volume of a Right Circular Cone. | Wikipedia reference: https://en.wikipedia.org/wiki/Cone :return: :math:`\frac{1}{
maths/volume.py:234
↓ 1 callersFunctionvol_spheres_union
r""" Calculate the volume of the union of two spheres that possibly intersect. It is the sum of sphere :math:`A` and sphere :math:`B` minus t
maths/volume.py:124
↓ 1 callersFunctionvol_torus
r""" | Calculate the Volume of a Torus. | Wikipedia reference: https://en.wikipedia.org/wiki/Torus :return: :math:`2 \pi^2 \cdot torus\_r
maths/volume.py:482
↓ 1 callersFunctionwarp
Warps the pixels of an image into a new image using the horizontal and vertical flows. Pixels that are warped from an invalid location ar
computer_vision/horn_schunck.py:18
↓ 1 callersFunctionweight_matrix
Calculate the weight of every point in the training data around a given prediction point Args: point: x-value at which the predi
machine_learning/local_weighted_learning/local_weighted_learning.py:38
↓ 1 callersFunctionweird
>>> weird(0) False >>> weird(70) True >>> weird(77) False
maths/special_numbers/weird_number.py:84
↓ 1 callersFunctionwiggle_sort
Python implementation of wiggle. Example: >>> wiggle_sort([0, 5, 3, 2, 2]) [0, 5, 2, 3, 2] >>> wiggle_sort([]) [] >>> wig
sorts/wiggle_sort.py:12
↓ 1 callersFunctionword_occurrence
>>> from collections import Counter >>> SENTENCE = "a b A b c b d b d e f e g e h e i e j e 0" >>> occurence_dict = word_occurrence(SENTE
strings/word_occurrence.py:6
↓ 1 callersFunctionworld_covid19_stats
Return a dict of current worldwide COVID-19 statistics
web_programming/world_covid19_stats.py:20
↓ 1 callersMethodwrite_block
(self, data, block_number)
sorts/external_sort.py:17
↓ 1 callersFunctionwrite_file_binary
Writes given to_write string (should only consist of 0's and 1's) as bytes in the file
data_compression/lempel_ziv.py:86
↓ 1 callersFunctionwrite_file_binary
Writes given to_write string (should only consist of 0's and 1's) as bytes in the file
data_compression/lempel_ziv_decompress.py:57
↓ 1 callersFunctionwrite_movies
(filename: str = "IMDb_Top_250_Movies.csv")
web_programming/get_imdb_top_250_movies_csv.py:28
↓ 1 callersFunctionxgboost
>>> xgboost(np.array([[ 2.3571 , 52. , 6.00813008, 1.06775068, ... 907. , 2.45799458, 40.58 , -124.26]]),np.array([1.114]), ... np
machine_learning/xgboost_regressor.py:20
↓ 1 callersFunctionxgboost
# THIS TEST IS BROKEN!! >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2]]), np.array([0])) XGBClassifier(base_score=0.5, booster='gbtree', callback
machine_learning/xgboost_classifier.py:24
↓ 1 callersFunctionxorshift
(x, y)
hashes/chaos_machine.py:46
↓ 1 callersFunctiony_generator
Generate y values for corresponding classes :param class_count: Number of classes(data groupings) in dataset :param instance_count: numbe
machine_learning/linear_discriminant_analysis.py:74
↓ 1 callersFunctionyears_old
Calculate the age in years based on the given birth date. Only the year, month, and day are used in the calculation. The time of day is ign
web_programming/get_top_billionaires.py:30
↓ 1 callersFunctionz_function
For the given string this function computes value for each index, which represents the maximal length substring starting from the index a
strings/z_function.py:13
↓ 1 callersFunctionzeller
| Zellers Congruence Algorithm | Find the day of the week for nearly any Gregorian or Julian calendar date >>> zeller('01-31-2010')
maths/zellers_congruence.py:5
↓ 1 callersFunctionzigzag
ZigZag traverse: Returns a list of nodes value from left to right and right to left, alternatively. >>> list(zigzag(make_tree()))
data_structures/binary_tree/binary_tree_traversals.py:163
Method__add__
(self, other: Variable)
machine_learning/automatic_differentiation.py:65
Method__add__
input: other vector assumes: other vector has the same size returns a new vector that represents the sum.
linear_algebra/src/lib.py:72
Method__add__
implements matrix addition.
linear_algebra/src/lib.py:287
Method__add__
(self, other)
maths/dual_number_automatic_differentiation.py:29
Method__add__
Polynomial addition >>> p = Polynomial(2, [1, 2, 3]) >>> q = Polynomial(2, [1, 2, 3]) >>> p + q 6x^2 + 4x + 2
maths/polynomials/single_indeterminate_operations.py:34
Method__add__
(self, other: Matrix)
matrix/matrix_class.py:298
Method__add__
<method Matrix.__add__> Return self + another. Example: >>> a = Matrix(2, 1, -4) >>> b = Matrix(2, 1, 3)
matrix/sherman_morrison.py:102
Method__bool__
Check if the heap is not empty. >>> sh = SkewHeap() >>> bool(sh) False >>> sh.insert(1) >>> bool(sh)
data_structures/heap/skew_heap.py:125
Method__bool__
Check if the heap is not empty. >>> rh = RandomizedHeap() >>> bool(rh) False >>> rh.insert(1) >>> bo
data_structures/heap/randomized_heap.py:202
Method__bool__
(self)
data_structures/binary_tree/binary_search_tree.py:133
Method__bool__
(self)
data_structures/binary_tree/red_black_tree.py:452
Method__bool__
(self)
data_structures/hashing/hash_map.py:29
Method__bool__
(self)
data_structures/stacks/stack.py:29
Method__call__
(self, v1, v2)
machine_learning/sequential_minimum_optimization.py:430
Method__contains__
(self, value: DataType)
data_structures/linked_list/doubly_linked_list_two.py:57
Method__contains__
Search through the tree for label, returning True iff it is found somewhere in the tree. Guaranteed to run in O(log(n)) time.
data_structures/binary_tree/red_black_tree.py:343
Method__contains__
(self, other: str)
data_structures/hashing/bloom_filter.py:80
Method__contains__
Check if item is in stack >>> S = Stack(3) >>> S.push(10) >>> 10 in S True >>> S = Stack(3)
data_structures/stacks/stack.py:144
Method__contains__
>>> cache = LRUCache(1) >>> 1 in cache False >>> cache.put(1, 1) >>> 1 in cache True
other/lru_cache.py:231
Method__contains__
>>> cache = LFUCache(1) >>> 1 in cache False >>> cache.put(1, 1) >>> 1 in cache True
other/lfu_cache.py:218
Method__delitem__
>>> hm = HashMap(5) >>> hm._add_item(1, 10) >>> hm._add_item(2, 20) >>> hm._add_item(3, 30) >>> hm.__delitem_
data_structures/hashing/hash_map.py:206
Method__enter__
(self)
machine_learning/automatic_differentiation.py:209
Method__eq__
(self, cell)
machine_learning/astar.py:39
Method__eq__
(self, value)
machine_learning/automatic_differentiation.py:152
Method__eq__
>>> WordCount('a', 1).__eq__(WordCount('b', 1)) True >>> WordCount('a', 1).__eq__(WordCount('a', 1)) True >>>
strings/top_k_frequent_words.py:28
Method__eq__
(self, other)
sorts/patience_sort.py:27
Method__eq__
Check if two points are equal. >>> Point(1, 2) == Point(1, 2) True >>> Point(1, 2) == Point(2, 1) False
geometry/graham_scan.py:52
Method__eq__
(self, other: object)
geometry/jarvis_march.py:32
Method__eq__
Check if the 2 objects are equal.
searches/hill_climbing.py:67
Method__eq__
performs the comparison between two vectors
linear_algebra/src/lib.py:98
Method__eq__
(self, other)
graphs/greedy_best_first.py:86
Method__eq__
(self, other)
divide_and_conquer/convex_hull.py:51
Method__eq__
Implements "==" operator. Returns if *self* is equal to *other*. Time complexity: O(n) >>> our_deque_1 = Deque([1, 2, 3])
data_structures/queues/double_ended_queue.py:375
Method__eq__
(self: T, other: object)
data_structures/heap/heap.py:18
Method__eq__
Test if two trees are equal.
data_structures/binary_tree/red_black_tree.py:502
Method__eq__
(self, other: object)
matrix/matrix_class.py:287
Method__eq__
(self, other)
project_euler/problem_054/sol1.py:337
Method__exit__
( self, exc_type: type[BaseException] | None, exc: BaseException | None, trace
machine_learning/automatic_differentiation.py:213
Method__floordiv__
(self, other)
maths/dual_number_automatic_differentiation.py:74
Method__ge__
(self, other)
divide_and_conquer/convex_hull.py:67
Method__ge__
(self, other)
project_euler/problem_054/sol1.py:357
Function__get_demo_graph
(index)
graphs/finding_bridges.py:13
Method__getitem__
Get all the vertices adjacent to the given one.
graphs/breadth_first_search_zero_one_shortest_path.py:29
Method__getitem__
Indexing Support. Used to get a node at particular position >>> linked_list = LinkedList() >>> for i in range(0, 10):
data_structures/linked_list/singly_linked_list.py:108
Method__getitem__
(self, key)
data_structures/heap/min_heap.py:39
Method__getitem__
Returns the item at the given key >>> hm = HashMap(5) >>> hm._add_item(1, 10) >>> hm.__getitem__(1) 10
data_structures/hashing/hash_map.py:267
Method__getitem__
<method Matrix.__getitem__> Return array[row][column] where loc = (row, column). Example: >>> a = Matrix(3, 2, 7)
matrix/sherman_morrison.py:75
Method__gt__
(self, other)
divide_and_conquer/convex_hull.py:57
Method__gt__
(self: T, other: T)
data_structures/heap/heap.py:14
Method__gt__
(self, other)
project_euler/problem_054/sol1.py:352
Method__hash__
(self)
geometry/jarvis_march.py:40
Method__hash__
hash the string representation of the current search state.
searches/hill_climbing.py:61
Method__hash__
>>> hash(Node(3)) != 0 True
graphs/deep_clone_graph.py:28
Method__hash__
(self)
divide_and_conquer/convex_hull.py:84
Method__hash__
(self)
project_euler/problem_054/sol1.py:362
Method__init__
(self, depth=5, min_leaf_size=5)
machine_learning/decision_tree.py:11
Method__init__
( self, *, regularization: float = np.inf, kernel: str = "linear", gam
machine_learning/support_vector_machines.py:54
Method__init__
@raises ValueError: if the polynomial degree is negative
machine_learning/polynomial_regression.py:44
Method__init__
Initialize a GradientBoostingClassifier. Parameters: - n_estimators (int): The number of weak learners to train. - l
machine_learning/gradient_boosting_classifier.py:9
Method__init__
(self)
machine_learning/astar.py:27
← previousnext →2,301–2,400 of 3,909, ranked by callers