Skip to content

Commit abe098f

Browse files
BurhanHpoyeaphileasmedimgrichrDevilLord9967
authored
Fetching last changes (#1)
* Improve doctest and comment for maximum sub-array problem (#1503) * Doctest and comment for maximum sub-array problem More examples and description for max_sub_array.py * Update max_sub_array.py * Update max_sub_array.py * Fix doctest * Page replacement algorithm, LRU (#871) * Page replacement algorithm, LRU * small rectifications * Rename paging/LRU.py to other/least_recently_used.py * Addition of Secant Method (#876) * Add files via upload * Update secant_method.py * Remove unused import * Remove unused import * Create GAN.py (#1445) * Create GAN.py * gan update * Delete train-labels-idx1-ubyte.gz * Update GAN.py * Update GAN.py * Delete GAN.py * Create gan.py * Update gan.py * input_data import file * Update dictionary.txt (#1507) Added a new word Microfinance. This is one of the recently added word in oxford dictionary * Update greatest_common_divisor.py (#1513) Add Doctests. * Update palindrome.py (#1509) * Update palindrome.py Add Doctests. * Use test_data to drive the testing * :white_check_mark: added tests for Perceptron in Neural Networks (#1506) * :white_check_mark: added tests for Perceptron in Neural Networks * Space * Format code with psf/black * Add doctests to other/word_patterns.py (#1518) * Create prime_numbers.py (#1519) * Create prime_numbers.py * Update prime_numbers.py * Update basic_maths.py (#1517) * Update basic_maths.py Add Doctests. * Update basic_maths.py * Add a space to fix the doctest * Factors of a number (#1493) * Factors of a number * Update factors.py * Fix mypy issue in basic_maths.py * Fix mypy error in perceptron.py * def primes(max: int) -> List[int]: * Update binomial_heap.py * Add a space * Remove a space * Add a space * average_mode.py (#1491) * Add files via upload Finds the mode in the input data. * Update average_mode.py * Update average_mode.py * Update average_mode.py * Update average_mode.py * Update average_mode.py * Update average_mode.py * Tabs do not belong in Python files! * Simplified DES (#1382) * Simplified DES * Add files via upload Diffie Hellman algorithm to generate a secret key. * Update sdes.py * Format code with psf/black and add doctests * Update quick_select.py (#1523) * Update quick_select.py Add Doctests. * Add typehints * Don't pre-allocate "smaller" and "larger" * Doctest, type hints and bug in LIS_O(nlogn) (#1525) * Update longest_increasing_subsequence_o(nlogn).py * Update longest_increasing_subsequence_o(nlogn).py * Euler Problem 27 solution script Added (#1466) * Add files via upload * Update DIRECTORY.md * Create sol1.py * Update sol1.py * Create __init__.py * Update DIRECTORY.md * Delete isotonic.py * Update sol1.py * Problem_27_project_euler * project_euler/Problem_27/sol1.py * project_euler/Problem_27/sol1.py * project_euler/problem_27/ * project_euler/problem_27 * project_euler/problem_27 * update sol1 of Euler Problem 27 solution script Added * Remove slow test, wrap long comments, format with psf/black * Delete __init__.py * Add type hints * Add doctests to function is_prime() * Rename project_euler/problem_27/project_euler/problem_27/sol1.pysol1.py to project_euler/problem_27/problem_27_sol1.py * perfect square (#1534) * perfect square * perfect square * Added Problem 33 (#1440) * Create sol1.py * Create __init__.py * Update sol1.py * corrected range * Update sol1.py * update factorial (#1535) * update factorial * update factorial * add max sum contigous subsequence (#1537) * add max sum contigous subsequence * fix typo * Add doctest and type hints * Create autoblack.yml * recursive quick sort (#1536) * recursive quick sort * recursive quick sort * Delete recursive-quick-sort * Update recursive-quick-sort.py * Non-recursive Segment Tree implementation (#1543) * Non-recursive Segment Tree implementation * Added type hints and explanations links * Travis CI: Write & print DIRECTORY.md on one line (#1542) * travis test * travis pull ID test * get pr branch test * retry pr build * test pushing back - probable git error for origin 'not found' * github auth? * add .sh * chmod * add index update for permission fix * run sh for script * add all * add pull directory * fetch pr branch * swap placement of adding commits * rotate * quit trying to update Travis * formatting leftovers * Travis CI: Write & print DIRECTORY.md on one line * added solution 1 for problem_99 in project_euler (#1545) * Create sol1.py * Create __init__.py * Update sol1.py * corrected range * Add files via upload * Update DIRECTORY.md * Create sol1.py * Update sol1.py * Create __init__.py * Update DIRECTORY.md * Delete isotonic.py * Update sol1.py * Problem_27_project_euler * project_euler/Problem_27/sol1.py * project_euler/Problem_27/sol1.py * project_euler/problem_27/ * project_euler/problem_27 * project_euler/problem_27 * update sol1 of Euler Problem 27 solution script Added * Remove slow test, wrap long comments, format with psf/black * Delete __init__.py * Add type hints * Add doctests to function is_prime() * Rename project_euler/problem_27/project_euler/problem_27/sol1.pysol1.py to project_euler/problem_27/problem_27_sol1.py * Added Problem 33 * added solution 1 for problem_99 * update added solution 1 for problem_99 * update * Update sol1.py * add floor() (#1551) * ceil and floor * ceil and floor * Porta cipher (#1550) * directory_writer * add porta cipher for #1492 * formatting and one line comprehensions * remove directory_writer * indentions * Wrap long lines * Doctest and typing for longest_increasing_subsequence.py (#1526) * Update longest_increasing_subsequence.py * Update longest_increasing_subsequence.py * Format longest_increasing_subsequence.py to PEP8 * Update longest_increasing_subsequence.py * Add sol3 for project_euler problem_03 (#1553) * Add sol3 for project_euler proble_03 * Update sol3.py add type hint remove unused variable * Format code with psf/black * added rsa_factorization.py (#1556) * added RSA_factorization.py This algorithm can effectively factor RSA large prime N given public key e and private key d. * Rename RSA_factorization.py to rsa_factorization.py * Add definitions for d, e, and N * Improved on Singly Linked List Programs (#1558) * Improved Singly Linked List Added String Representations of Nodes and Linked Lists Added support for indexing and changing of Node data using indices. * Added a few comments to Linked Lists * Reformatted to conform to PEP8 * Added from_sequence.py Convert a Python List to Linked List comprising of Nodes and return head. * Added print_reverse.py Recursive program to print the elements of a Linked List in reverse. * Change 'is not None' for more Pythonicness * Fix bug in bellman_ford.py (#1544) * Python Program that fetches top trending news (#1559) * Python Program that fetches top trending news * Python Program that fetches top trending news * Revisions in Fetch BBC News * Added a new Python script and some changes in existing one (#1560) * Python Program that fetches top trending news * Python Program that fetches top trending news * Revisions in Fetch BBC News * psf/black Changes * Python Program to send slack message to a channel * Slack Message Revision Changes * Moved to TheAlgorithms/Jupyter (#1563) https://github.com/TheAlgorithms/Jupyter/tree/master/other * Panagram Script Added (#1564) * Python Program that fetches top trending news * Python Program that fetches top trending news * Revisions in Fetch BBC News * psf/black Changes * Python Program to send slack message to a channel * Slack Message Revision Changes * Python Program to check Palindrome String * Doctest Added * Python Program to check whether a String is Panagram or not * Python Program to check whether a String is Panagram or not * Check Panagram Script Added * Panagram Script Added * Anagram Script Changes * Anagram Alphabet Check Added * Python Program to fetch github info * add sol3 to project_euler/problem_08 (#1557) * Add sol3 for project_euler proble_03 * Update sol3.py add type hint remove unused variable * Format code with psf/black * add sol3 to project_euler/problem_08, modify the stepsize of the loop,will be faster than sol1 * GitHub Action formats our code with psf/black (#1569) * GitHub Action formats our code with psf/black @poyea Your review please. * fixup! Format Python code with psf/black push * directory_writer (#1) (#1549) * directory_writer * fixup: Format Python code with psf/black * fixup: DIRECTORY.md * fix implementation errors. (#1568) I revised my implementation and found out that I have miss a inner loop for t. x and y should be recalculated everytime when t is divisble by 2. I have also included a more readble source for this algorithm. * Remove Duplicate Script Added (#1570) * Added Remove duplicate script and updated requirements.txt * Requirements.txt Updated * Remove Duplicate Script Added * Directory Modified * Directory.md Updated * changed implementation of GitHub action to auto update DIRECTORY.md (#1571) * changed implementation of GitHub action to auto update DIRECTORY.md * updating DIRECTORY.md * || true (#1572) * || true * 3.8 * python: 3.x * Fix indentation contains tabs (flake8 E101,W191) (#1573) * Word Occurence Script Added (#1576) * Word Occurence Script Added * Word Occurence Script Updated * Added doctest using collections.Counter https://docs.python.org/3/library/collections.html#collections.Counter * Add pytest-cov (#1578) * Add pytest-cov Also added coverage report in .travis.yml file. * updating DIRECTORY.md * Sort by missing statements * sort = Cover * Remove code with side effects from main (#1577) * Remove code with side effects from main When running tests withy pytest, some modules execute code in main scope and open plot or browser windows. Moves such code under `if __name__ == "__main__"`. * fixup! Format Python code with psf/black push * Adding circular_queue.py (#1574) * Create circular_queue.py Circular Queue implementation using python list with fixed range. * Update circular_queue.py * Update circular_queue.py * Update circular_queue.py * Update circular_queue.py * Update circular_queue.py * doctest: Catch "Exception: UNDERFLOW" * Deal with the fluent interface for cq.enqueue() * Test the fluent interface * Reverse Words (#1581) * Word Occurence Script Added * Word Occurence Script Updated * Added doctest using collections.Counter https://docs.python.org/3/library/collections.html#collections.Counter * Reverse Word Script Added * Reverse Word Script Added * Reverse Word Script Added * Reverse Word Script Added * Word Occurence Script Added * Reverse Word Script Added * Reverse Word Script Added * Reverse Words DocTest Updated * Word Occurence Updated * Doctest Updated * Doctest Updated * Doctest Updated * Adds operations for circular linked list (#1584) * Adds, append, len, print operations for circular linked list * Adds, prepend support * Adds, delete from front of the list * Adds, delete_rear support * Adds, method documentations * Adds, type checking and doctests * Updates doctest for delete ops * Addressing requested changes * Removes unused import * Fixes failing doctests * Minor modifications... * Improve bellman_ford.py (#1575) * Fix out of range error in bellman_ford.py * Update bellman_ford.py * fixup! Format Python code with psf/black push * Enhance the print function * fixup! Format Python code with psf/black push * Update gaussian_filter.py (#1548) * Update gaussian_filter.py Changed embedded for loops with product. This way range(dst_height) is called only once, instead of being called $dst_height. * Update gaussian_filter.py fixed missing width * Tabs --> spaces in quine_mc_cluskey.py (#1426) * Tabs --> spaces in quine_mc_cluskey.py * fixup! Format Python code with psf/black push * Fractional knapsack (#1524) * Add files via upload * Added doctests, type hints, f-strings, URLs * Rename knapsack.py to fractional_knapsack.py * Rename graphs/fractional_knapsack.py to dynamic_programming/fractional_knapsack_2.py * Update README.md (#1588) * Update README.md * python -m unittest -v * added current stock price (#1590) * added current stock price * Ten lines or less * Implemented simple keyword cipher (#1589) * Implemented simple keyword cipher * Added documentation and improved input processing * Allow object's hash function to be called * added to string functionality * reverted * Revised according to pull request #1589 * Optimized imports * Update simple_keyword_cypher.py * Update hash_table.py * Update singly_linked_list.py (#1593) * Update singly_linked_list.py printing current.data rather than node address in __repr__ for a more readable print statement * eval(repr(c)) == c The output of `__repr__()` _should look like a valid Python expression that could be used to recreate an object with the same value_. https://docs.python.org/3.4/reference/datamodel.html#object.__repr__ * += --> + * Adding Linear Discriminant Analysis (#1592) * Adding new file to the machine_learning directory * Adding initial documentation * importing modules * Adding Normal_gen function * Adding Y_gen function * Adding mean_calc function * Adding prob_calc function * Adding var_calc function * Adding predict function * Adding accuracy function * Adding main function * Renaming LDA file * Adding requested changes * Renaming some of functions * Refactoring str.format() statements to f-string * Removing unnecessary list objects inside two functions * changing code style in some lines * Fixing y_generator function * Refactoring 'predict_y_values' function by using list comprehensions * Changing code style in import statements * Refactoring CLI code block * fixup! Format Python code with psf/black push * No lines longer than 88 characters * GitHub Action to mark stale issues and pull requests (#1594) * converting generator object to a list object (#1602) * converting generator object to a list object * Refactor: converting generator object to a list object * fixup! Format Python code with psf/black push * Typo in a comment (#1603) * add a generic heap (#906) * add a generic heap * Delete __init__.py * Rename data_structures/Heap/heap_generic.py to data_structures/heap/heap_generic.py * Add doctests * Fix doctests * Fix doctests again * Improve prim.py (#1226) * suiting PEP8 * create auxiliary function * running example * updating DIRECTORY.md * Pythagoras (#1243) * add pythagoras.py * function distance * run as script * Update pythagoras.py * Code for Eulers Totient function (#1229) * Create eulersTotient.py * Rename eulersTotient.py to eulers_totient.py * Update eulers_totient.py * fixed bug (#1610) Removed comma from print statement causing and error. * Added Multilayer Perceptron (sklearn) (#1609) * Added Multilayer Perceptron ( sklearn) * Rename MLPClassifier.py to multilayer_preceptron_classifier.py * Rename multilayer_preceptron_classifier.py to multilayer_perceptron_classifier.py * Update multilayer_perceptron_classifier.py * address merge_soft duplicate files (#1612) Here the old file merge_sort_fastest is renamed to unknown_sort. Because it is not merge sort algorithm. Comments are updated accordingly. * add the index calculation class at digital_image_processing and the hamming code algorithm at hashes (#1152) * add the index calculation at difital_image_processing file * make changes at index_calculation * update the variables to self variables at functions * update the word wrap in comments at index_calculation * add the hamming code algorithm * Wrap long lines * pigeonhole sorting in python (#364) * pigeonhole sorting in python * variable name update in pigeonhole_sort.py * Add doctest * improved prime numbers implementation (#1606) * improved prime numbers implementation * fixup! Format Python code with psf/black push * fix type hint * fixup! Format Python code with psf/black push * fix doctests * updating DIRECTORY.md * added prime tests with negative numbers * using for instead filter * updating DIRECTORY.md * Remove unused typing.List * Remove tab indentation * print("Sorted order is:", " ".join(a)) * Improved readability (#1615) * improved readability * further readability improvements * removed csv file and added f * Simplify sudoku.is_completed() using builtin all() (#1608) * Simplify sudoku.is_completed() using builtin all() Simplify __sudoku.is_completed()__ using Python builtin function [__all()__](https://docs.python.org/3/library/functions.html#all). * fixup! Format Python code with psf/black push * Update sudoku.py * fixup! Format Python code with psf/black push * Old style exception -> new style for Python 3 * updating DIRECTORY.md * Update convex_hull.py * fixup! Format Python code with psf/black push * e.args[0] = "msg" * ValueError: could not convert string to float: 'pi' * Update convex_hull.py * fixup! Format Python code with psf/black push * Adding doctests into LDA algorithm (#1621) * Adding doctests into <gaussian_distribution> function * Adding doctests into <y_generator> function * Adding doctests into <calculate_mean> function * Adding doctests into <calculate_probabilities> function * Adding doctests into <calculate_variance> function * Adding doctests into <predict_y_values> function * Adding doctests into <accuracy> function * fixup! Format Python code with psf/black push * Update convex_hull.py * Update convex_hull.py * Fixed issue #1368 (#1482) * Changed as suggested Now return in same format as oct() returns * Slight change * Fixed issue #1368, return values for large number now is fixed and does not return in scientific notation * Update decimal_to_octal.py * Update odd_even_transposition_parallel.py (#1458) * Update odd_even_transposition_parallel.py * arr = OddEvenTransposition(arr) * digital_image_processing/convert_to_negative (#1216) * digital_image_processing/convert_to_negative * added doc * added test code * Update convert_to_negative.py * Image processing algorithms added (#616) * Image processing algorithms added * Example images included * Issues resolved * class added * Naming issues fixes * Create file_path * Remove \r from strings (#1622) * Remove \r from strings * Satisfy tensorflow with numpy>=1.17.4 * Update find_min.py (#1627) Line 5: :return: max number in list "max" must be "min" * Harmonic Geometric and P-Series Added (#1633) * Harmonic Geometric and P-Series Added * Editing comments * Update and rename series/Geometric_Series.py to maths/series/geometric_series.py * Update and rename series/Harmonic_Series.py to maths/series/harmonic_series.py * Update and rename series/P_Series.py to maths/series/p_series.py * Bug Fixed in newton_raphson_method.py (#1634) * Bug Fixed * Fixed newton_raphson_method.py * Fixed newton_raphson_method.py 2 * Fixed newton_raphson_method.py 3 * Fixed newton_raphson_method.py 4 * Fixed newton_raphson_method.py 5 * Fixed newton_raphson_method.py 6 * Update newton_raphson_method.py * Update newton_raphson_method.py * # noqa: F401, F403 * newton_raphson * newton_raphson * precision: int=10 ** -10 * return float(x) * 3.1415926536808043 * Update newton_raphson_method.py * 2.23606797749979 * Update newton_raphson_method.py * Rename newton_raphson_method.py to newton_raphson.py * adding doctests on coin_change.py and fixed some typos (#1337) * adding doctests on coin_change.py * fixed some typos * Update lib.py * file iterating_through_submasks.py for given mask is added in dynamic_programming (#1635) * new file *iterating_through_submasks* is added in dynamic_programming section * no changes * *iterating_through_submasks.py is added in dynamic_programming * iterating_through_submasks is added with doctests * iterating_through_submasks.py is added in dynamic_programming * changes made in *iterating_through_submasks.py * changes made in *iterating_through_submasks.py * updated * Add docstr and algorithm to BFS shortest path module (#1637) * Add docs and type alias to bfs_shortest_path.py * Add bfs_shortest_path_distance algorithm * Make requested changes * other/integeration_by_simpson_approx.py is added for approximate integeration (#1638) * new file *iterating_through_submasks* is added in dynamic_programming section * no changes * *iterating_through_submasks.py is added in dynamic_programming * iterating_through_submasks is added with doctests * iterating_through_submasks.py is added in dynamic_programming * changes made in *iterating_through_submasks.py * changes made in *iterating_through_submasks.py * updated * *other/integeration_by_simpson_approx.py added * *other/integeration_by_simpson_approx.py Added for integeration * Delete iterating_through_submasks.py * Delete DIRECTORY.md * Revert "updated" This reverts commit 73456f85de03782b7d3c794eca8390a4fe87037c. * changes made *integeration_by_simpson_approx.py * update2 Co-authored-by: Christian Clauss <[email protected]> * Fixed warning string for Key B = 0 (#1639) * Fixed warning string for Key B = 0 * Update affine_cipher.py * Update affine_cipher.py * decrypt_message(encrypt_message()) Co-authored-by: Christian Clauss <[email protected]> * Create roman_to_integer.py (#1636) * added roman to integer conversion (LeetCode No. 13) * updated directory to include Roman to Integer * Delete DIRECTORY.md * Update roman_to_integer.py Co-authored-by: Christian Clauss <[email protected]> * Update binary_search_tree.py (#1339) * Update binary_search_tree.py remove some bugs * Update binary_search_tree.py * Update binary_search_tree.py * Update binary_search_tree.py * Update binary_search_tree.py * Update binary_search_tree.py * Update binary_search_tree.py * testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7) * Update .travis.yml Co-authored-by: Christian Clauss <[email protected]> * Stack using double linked list (#1413) * Stack using double linked list * Test with doctests * Update stack_using_dll.py * Update stack_using_dll.py * Update stack_using_dll.py Co-authored-by: Christian Clauss <[email protected]> * Added binary exponentiaion with respect to modulo (#1428) * Added binary exponentiaion with respect to modulo * Added miller rabin: the probabilistic primality test for large numbers * Removed unused import * Added test for miller_rabin * Add test to binary_exp_mod * Removed test parameter to make Travis CI happy * unittest.main() # doctest: +ELLIPSIS ... * Update binary_exp_mod.py * Update binary_exp_mod.py * Update miller_rabin.py * from .prime_check import prime_check Co-authored-by: Christian Clauss <[email protected]> * Update back_propagation_neural_network.py (#1342) * Update back_propagation_neural_network.py Added comments below functions * Update back_propagation_neural_network.py Co-authored-by: Christian Clauss <[email protected]> * actions/checkout@v2 (#1643) * actions/checkout@v2 https://github.com/actions/checkout/releases * fixup! Format Python code with psf/black push * pyupgrade --py37-plus **/*.py (#1654) * pyupgrade --py37-plus **/*.py * fixup! Format Python code with psf/black push * Dijkstra's Bankers algorithm (#1650) * Dijkstra's Bankers algorithm @bluedistro, Your review please. A second shot at #1645 Implementation of the Dijkstra's Banker's algorithm with test examples and a comprehensible description. * fixup! Format Python code with psf/black push * Delete back_propagation_neural_network.py * Create back_propagation_neural_network.py * fixup! Format Python code with psf/black push * Add files via upload (#1657) * update volumes with type hints + some refactoring (#1353) * update volumes with type hints + some refactoring * added docstrings * Use float instead of ints in doctest results Co-authored-by: Christian Clauss <[email protected]> * Create deque_doubly.py (#1652) * Create deque_doubly.py Implementing Deque ADT using Doubly Linked List.... * Update deque_doubly.py * Update deque_doubly.py Adding doctest * Update doctest of deque_doubly.py * Update deque_doubly.py * linked_list. Co-authored-by: Christian Clauss <[email protected]> * Create get_imdb_top_250_movies_csv.py (#1659) * Create get_imdb_top_250_movies_csv.py * Update get_imdb_top_250_movies_csv.py * Update get_imdb_top_250_movies_csv.py * get_imdb_top_250_movies() Co-authored-by: Christian Clauss <[email protected]> * New Code!!(Finding the N Possible Binary Search Tree and Binary Tree from Given N node Number) (#1663) * Code Upload * Code Upload * Delete n_possible_bst * Find the N Possible Binary Tree and Binary Tree from given Nth Number of Node. * Update in Test * Update and rename n_possible_bst.py to number_of_possible_binary_trees.py Co-authored-by: Christian Clauss <[email protected]> * added hill climbing algorithm (#1666) * added hill climbing algorithm * Shorten long lines, streamline get_neighbors() * Update hill_climbing.py * Update and rename optimization/hill_climbing.py to searches/hill_climbing.py Co-authored-by: Christian Clauss <[email protected]> * number of Possible Binary Search Tree and Binary Tree. (#1670) * Code Upload * Code Upload * Delete n_possible_bst * Find the N Possible Binary Tree and Binary Tree from given Nth Number of Node. * Update in Test * Update and rename n_possible_bst.py to number_of_possible_binary_trees.py Co-authored-by: Christian Clauss <[email protected]> * Typos in comments in hill_climbing.py (#1667) * Typos in comments in hill_climbing.py * fixup! Format Python code with psf/black push * Update and rename lca.py to lowest_common_ancestor.py (#1664) * Update and rename lca.py to lowest_common_ancestor.py * fixup! Format Python code with psf/black push * Added to maths and strings (#1642) * Added to maths and strings * added changes suggest by cclauss * git add DIRECTORY.md (#1674) * git add DIRECTORY.md * updating DIRECTORY.md * Added Strassen divide and conquer algorithm to multiply matrices. (#1648) * Added Strassen divide and conquer algorithm to multiply matrices * Divide and conquer algorith to calculate pow(a,b) or a raised to the power of b * Putting docstring inside the function. * Added doctests * Corrects failing check in master (#1676) * Add a program to evaluate a string in prefix notation (Polish Notation) (#1675) * Create infix_evaluation.py * fix doctests * Rename infix_evaluation.py to prefix_evaluation.py * Add prefix_evaluation.py to directory * A recursive insertion sort (#1683) * A recursive insertion sort * added doctests and typehints * Create pull_request_template.md (#1684) * Create pull_request_template.md * fixup! Format Python code with psf/black push * Update pull_request_template.md * updating DIRECTORY.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Typos and formatting Co-authored-by: John Law <[email protected]> * enhance swapping code in link (#1660) * enhance swapping code in link * heapify do not recursive * fix * fix identifier and add test * typing.Any and LinkedList instead of Linkedlist * typing.Any and LinkedList instead of Linkedlist * Typo? (#1653) * Typo? newNod -> newNode * newNode -> new_node Co-authored-by: Christian Clauss <[email protected]> * implement max heap and more pythonic (#1685) * implement max heap and more pythonic * add doctests for heap * Implemented Square Root Algorithm (#1687) * Added to maths and strings * added changes suggest by cclauss * added square root function * Fixed type hinting * fixed type error * Fixed another type error * Solution for problem 30 of Euler Project (#1690) * Create soln.py Solution for problem 30 of Euler Project * Update soln.py * update soln.py modified the changes * if __name__ == "__main__": Co-authored-by: Christian Clauss <[email protected]> * Added implementation for simulated annealing (#1679) * added hill climbing algorithm * Shorten long lines, streamline get_neighbors() * Update hill_climbing.py * Update and rename optimization/hill_climbing.py to searches/hill_climbing.py * added hill climbing algorithm * Shorten long lines, streamline get_neighbors() * Update hill_climbing.py * Rebased * added simulated annealing.py * added final comments and test * black formatted * restricted search domain Co-authored-by: Christian Clauss <[email protected]> * Create codespell.yml (#1698) * fixup! Format Python code with psf/black push * Create codespell.yml * fixup! Format Python code with psf/black push * Create factorial_iterative.py (#1693) * Create factorial_iterative.py * Update factorial_iterative.py * Update factorial_iterative.py * Update factorial_iterative.py * print(f"factorial{n} is {factorial(n)}") * Update factorial_recursive.py Co-authored-by: Christian Clauss <[email protected]> * Added an algorithm that approximates line lengths (#1692) * A recursive insertion sort * added doctests and typehints * Added arc length and numerical integration calculators * fixed doc test * Fixed some conversion errors * Fixed some commenting * Deleted numerical integration to allow 1 file per push * Changed string formatting method * Area Under a Curve Algorithm (#1701) * A recursive insertion sort * added doctests and typehints * Added arc length and numerical integration calculators * fixed doc test * Fixed some conversion errors * Fixed some commenting * Deleted numerical integration to allow 1 file per push * Changed string formatting method * Added program to calculate trapezoidal area under curve * Deleted files ensure 1 pull request per file * file name changed * Update area_under_curve.py Co-authored-by: Christian Clauss <[email protected]> * Add Prim's algorithm with min heap (#1704) * Adding Armstrong number (#1708) * Adding Armstrong number * Update armstrong_numbers * Update armstrong_numbers.py * Update armstrong_numbers.py * Update armstrong_numbers.py Co-authored-by: Christian Clauss <[email protected]> * fix comment (#1710) * fix comment * Update armstrong_numbers.py Co-authored-by: Christian Clauss <[email protected]> * codespell --quiet-level=2 (#1711) * codespell --quiet-level=2 Suppress the BINARY FILE warnings * fixup! Format Python code with psf/black push * Added implementation for Bezier Curve, under a new graphics directory. (#1713) * Added bezier curve * black formatted * corrected spell check * edited scipy import * updated documentation for readablitity * Update bezier_curve.py * Update bezier_curve.py Co-authored-by: Christian Clauss <[email protected]> * Mandates referencing issue in PR (#1717) * Mandates referencing issue in PR * Update CONTRIBUTING.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update CONTRIBUTING.md Co-authored-by: John Law <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * Fix typo (#1718) * Fix typo * updating DIRECTORY.md * Augment binary search algorithms (#1719) * relevant documentation added (#1725) * Implement Manacher's algorithm (#1721) * manacher's algorithm updated * Added first come first served scheduling (#1722) * Added FCFS * Fixed spelling error * Rename fcfs.py to first_come_first_served.py * Fixed FCFS and added tests. * Made changes requested * Use enumerate() instead of range(len()) Co-authored-by: Christian Clauss <[email protected]> * Improve collatz_sequence algorithm (#1726) - Add more doctests and type checking to make sure only natural numbers are used - Simplified the algorithm slightly This new verison is also between 10-15% faster for really long sequences * Added Random Forest Regressor and tested with flake8 (#1733) * Added Random Forest Regressor * Updated file to standard * Travis CI: Don’t allow bare exceptions (#1734) * Travis CI: Don’t allow bare exceptions * fixup! Format Python code with psf/black push * except IOError: * except IOError: * Update hamming_code.py * IndexError * Get rid of the nonsense logic Co-authored-by: John Law <[email protected]> * Added a Monte Carlo simulation (#1723) * Added montecarlo.py This algorithm uses a Monte Carlo simulation to estimate the value of pi. * Rename montecarlo.py to maths/montecarlo.py * Add files via upload * Delete montecarlo.py * Rename montecarlo.py to maths/montecarlo.py * Update montecarlo.py * Fixes black failures (#1742) * Fixes LGTM issues (#1745) * Fixes redefinition of a variable * Fixes implementing __eq__ * Updates docstring * Add gitpod config (#1744) * Add gitpod config * Add Gitpod to icon bar * Added DP Solution for Optimal BST Problem (#1740) * Added code to dynamic_programming directory * Added doctest * Elaborated BST * Small tweaks * Update optimal_bst.py * Some touchups * Fixed doctest * Update optimal_bst.py * Update optimal_bst.py * Update optimal_bst.py * Rename optimal_bst.py to optimal_binary_search_tree.py Co-authored-by: Christian Clauss <[email protected]> * Added Bisection algorithm (#1739) * Create Bisection.py Find root of * Update Bisection.py * Update Bisection.py i changed the given function with one that i could make the doctests. * Rename Bisection.py to bisection.py * Update bisection.py * Update bisection.py * Update bisection.py * Update bisection.py * Update bisection.py Made the changes that were requested * Update bisection.py * Update bisection.py * Add wiki url Co-authored-by: Christian Clauss <[email protected]> * Fixes unused variable errors in LGTM (#1746) * Fixes unsed variable errors in LGTM * Fixes integer check * Fixes failing tests * Add Chudnovskys algorithm for calculating many digits of pi (#1752) * Add Chudnovskys algorithm for calculating many digits of pi * Update return value type hint * Initialize partial sum to be of type Decimal * Update chudnovsky_algorithm.py Co-authored-by: Christian Clauss <[email protected]> * Fixes black failures from Previous PR (#1751) * Fixes black failures from Previous PR * Fixes equality testing alert * Fixes call to main() alert * Fixes unused import * Create RayleighQuotient.py (#1749) * Create RayleighQuotient.py https://en.wikipedia.org/wiki/Rayleigh_quotient * Update RayleighQuotient.py * Update and rename RayleighQuotient.py to rayleigh_quotient.py * Update rayleigh_quotient.py * Update rayleigh_quotient.py python/black * Update rayleigh_quotient.py * Created geodesy section with one algorithm (#1757) * implemented haversine * updated docstring Only calculate distance * added type hints * added type hints * improved docstring and math usage * f"{haversine_distance(*SAN_FRANCISCO, *YOSEMITE):0,.0f} meters" Co-authored-by: Christian Clauss <[email protected]> * Add Monte Carlo dice simulation algorithm (#1759) * Implement basic dice simulation * Add tests to throw_dice * Fix comment * Add type hints * Add additional comments * Update monte_carlo_dice.py Co-authored-by: Christian Clauss <[email protected]> * Update quadratic equations solver (#1764) Use pythons complex number module cmath for the calculation of the roots * Added doctests in modular_exponential.py (#1775) * added doctests in modular_exponential.py * added doctests in modular_exponential.py * added URL link * Implemented geodesy - Lambert's ellipsoidal distance (#1763) * Implemented Lambert's long line * Update lamberts_ellipsoidal_distance.py Co-authored-by: John Law <[email protected]> * uses: actions/checkout@v2 (#1779) * uses: actions/checkout@v2 * fixup! Format Python code with psf/black push * add example to estimate area under line using montecarlo (#1782) * add example to estimate area under line using montecarlo * separate estimate func and print statements * use mean from stats package * avoid creating extra variable * min_value: float=0.0, max_value: float=1.0 * Update montecarlo.py * Update montecarlo.py * Rename montecarlo.py to monte_carlo.py * Update monte_carlo.py Co-authored-by: Christian Clauss <[email protected]> * extend estimation of area under curve of y=x using monte carlo simulation to any given lower and upper bound (#1784) * extend estimation of area under curve of y=x using monte carlo simulation to any given lower and upper bound * remove doctest * Travis CI: Upgrade to Python 3.8 (#1783) * Travis CI: Upgrade to Python 3.8 * updating DIRECTORY.md * Tensorflow is not yet compatible with Python 3.8 * Disable k_means_clustering_tensorflow.py * updating DIRECTORY.md * Disable gan.py * updating DIRECTORY.md * Disable input_data.py * updating DIRECTORY.md * pip install a current version of six * estimate area under a curve defined by non-negative real-valued continuous function within a continuous interval using monte-carlo (#1785) * estimate area under a curve defined by non-negative real-valued continuous function within a continuous interval using monte-carlo * run black; update comments * Use f”strings” and drop unnecessary returns Co-authored-by: Christian Clauss <[email protected]> * Add bilateral filter (#1786) * Added Bilateral filter * Added Bilateral filter * changed types of varS and varI * formatted with black * added type hints * changed variable names * Update bilateral_filter.py * Drop transitory variables, add parse_args() Co-authored-by: vinayak <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * Create emails_from_url.py (#1756) * Create emails_from_url.py * Update emails_from_url.py * Update emails_from_url.py * 0 emails found: * Update emails_from_url.py * Use Python set() to remove duplicates * Update emails_from_url.py * Add type hints and doctests Co-authored-by: vinayak <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * contribution guidelines checks (#1787) * spelling corrections * review * improved documentation, removed redundant variables, added testing * added type hint * camel case to snake case * spelling fix * review * python --> Python # it is a brand name, not a snake * explicit cast to int * spaces in int list * "!= None" to "is not None" * Update comb_sort.py * various spelling corrections in documentation & several variables naming conventions fix * + char in file name * import dependency - bug fix Co-authored-by: John Law <[email protected]> * Added SkipList (#1781) * Added SkipList * Add missing type hints and doctests * Add missing doctest * Tighten up doctest Co-authored-by: Christian Clauss <[email protected]> * update rot13.py (#1790) * update rot13.py * Update rot13.py * Type hints, doctests, URL to Wikipedia Co-authored-by: Christian Clauss <[email protected]> * add relu function (#1795) * Added Random Forest Classifier (#1738) * Added Random Forest Regressor * Updated file to standard * Added Random Forest Classifier (Iris dataset) and a Confusion Matrix for result visualization * autoblack: actions/checkout@v1 # Use v1, NOT v2 (#1796) * autoblack: actions/checkout@v1 # Use v1, NOT v2 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Fix typo (#1797) colision => collision * Effective directory writer (#1800) * updating DIRECTORY.md * Update directory_writer.yml Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * directory_writer: actions/checkout@v1 # Use v1, NOT v2 (#1799) * directory_writer: actions/checkout@v1 # Use v1, NOT v2 (#1796 * updating DIRECTORY.md * Add Monte Carlo estimation of PI (#1712) * Add Monte Carlo estimation of PI * Add type annotations for Monte Carlo estimation of PI * Compare the PI estimate to PI from the math lib * accuracy -> error * Update pi_monte_carlo_estimation.py Co-authored-by: John Law <[email protected]> * Travis CI: Fix Travis linter errors (#1802) * Travis CI: Fix Travis linter errors * fixup! Format Python code with psf/black push * Update .travis.yml * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Fix rehashing function will not call insert_data function (#1803) * Fix rehashing function will not call insert_data function * Fix typo * Update loop syntax instead of allocating a list Co-Authored-By: Christian Clauss <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * 'allocation_content_length' (#1808) * 'allocation_content_length' * 'allocation_number' * Delete allocation_content_length.py * Update allocation_number.py * Update allocation_number.py * number_of_bytes and partitions * Update allocation_number.py Co-authored-by: Christian Clauss <[email protected]> * All suggeted changes within additional time limit tests (#1815) * With all suggested changes :white_check_mark: possibly covered all the recommended guidelines * Updated with both slow and faster algorithms possibally covered all the recomendations * removed the time comparision part! * Update data_structures/stacks/next_greater_element.py Co-Authored-By: Christian Clauss <[email protected]> * Update data_structures/stacks/next_greater_element.py Co-Authored-By: Christian Clauss <[email protected]> * Update data_structures/stacks/next_greater_element.py Co-Authored-By: Christian Clauss <[email protected]> * Update data_structures/stacks/next_greater_element.py Co-Authored-By: Christian Clauss <[email protected]> * Add benchmark using timeit https://docs.python.org/3/library/timeit.html The performance delta between these two implementation is quite small... ``` next_greatest_element_slow(): 1.843442126 next_greatest_element(): 1.828941414 ``` * Optimize slow() to create fast() - Three algorithms in the race Three algorithms in the race * Use a bigger test array with floats, negatives, zero * Setup import next_greatest_element_fast Co-authored-by: Christian Clauss <[email protected]> * psf/black changes to next_greater_element.py (#1817) * psf/black changes to next_greater_element.py * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Typo in comment rabin_karp.py (#1820) * Update rabin_karp.py fix: typo * Update rabin_karp.py Co-authored-by: Christian Clauss <[email protected]> * Update reverse_words.py (#1825) The following update results in less lines of code and faster performance while preserving functionality. * Update basic_binary_tree.py (#1833) fixed some grammar mistakes * Update greedy.py (#1832) * Create Python/quantum/README.md (#1834) * Create Python/quantum/README.md Started at #1831 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Change gitpod configuration for python3. (#1827) * Fix typo "panagram" -> "pangram" (#1836) * Binary search tree using recursion (#1839) * Binary search tree using recursion * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update README.md (#1842) * CONTRIBUTING.md: Fix comments about the black formatter (#1841) * CONTRIBUTING.md: Fix comments about the black formatter Fixes #1840 * Update CONTRIBUTING.md * Update CONTRIBUTING.md * Update FUNDING.yml (#1829) * Update FUNDING.yml * fixup! Format Python code with psf/black push * Update FUNDING.yml * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Anup Kumar Panwar <[email protected]> * Update FUNDING.yml * Added new Algorithm to find middle element of Linked List (#1822) * Added new Algorithm to find middle element of Linked List * Rename MiddleElementOfLinkedList.py to middle_element_of_linked_list.py * changed "middle_element_of_linked_list.py" algorithm for taking input * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Update middle_element_of_linked_list.py * Whack the trailing whitespace Co-authored-by: Christian Clauss <[email protected]> * README.md: sumab() --> sum_ab() for consistancy (#1855) * README.md: sumab() --> sum_ab() for consistancy consistency * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * added add algorithm (#1856) * added add algorithm * Update and rename check/add.py to math/add.py Co-authored-by: Christian Clauss <[email protected]> * Test the exception conditions (#1853) * Text exception conditions These are ValueErrors, not AttributeErrors. * fixup! Format Python code with psf/black push * Update perceptron.py * Update perceptron.py * Update perceptron.py * Revert the test Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Fix some typos in random forest classifier (#1858) * Update year in LICENSE.md (#1848) * Rename math/add.py to maths/add.py (#1857) * Rename math/add.py to maths/add.py * fixup! Format Python code with psf/black push * Fix sum to add * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: John Law <[email protected]> * Update g_topological_sort.py (#1873) * Create gaussian_naive_bayes.py (#1861) * Create Gaussian_Naive_Bayes.py Added Gaussian Naive Bayes algorithm in the module machine learning * Rename Gaussian_Naive_Bayes.py to gaussian_naive_bayes.py * requirements.txt: pip install xgboost Co-authored-by: Christian Clauss <[email protected]> * CONTRIBUTING.md: What is an Algorithm? (#1885) * CONTRIBUTING.md: What is an Algorithm? We are seeing too many _how-to examples_ for using existing Python packages so we should define what we want algorithm contributions to be. * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update random_forest_regressor.py (#1880) * Update CONTRIBUTING.md (#1886) * Update abbreviation.py (#1887) * Initialize set with source in DFS (#1872) * Update dfs.py * Add type hints, rearrange doc-strings and comments * fixup! Format Python code with psf/black push * dfs -> depth_first_search Co-Authored-By: Christian Clauss <[email protected]> * dfs -> depth_first_search * Add doctest for DFS * fixup! Format Python code with psf/black push * Rename dfs.py to depth_first_search_dictionary.py * updating DIRECTORY.md * Rename depth_first_search_dictionary.py to depth_first_search_dfs.py * updating DIRECTORY.md * Rename depth_first_search.py to depth_first_search_2.py * updating DIRECTORY.md * Rename depth_first_search_dfs.py to depth_first_search.py * updating DIRECTORY.md Co-authored-by: John Law <[email protected]> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <[email protected]> * Update breadth_first_search.py (#1869) * Create is_palindrome.py (#1754) * Create is_palindrome.py * Update is_palindrome.py * Update is_palindrome.py Co-authored-by: Christian Clauss <[email protected]> * Create Python/bit_manipulation/README.md (#1897) * Create Python/bit_manipulation/README.md To open up a new area of algorithms... @Shrutikabansal I hope that you will contribute some of your work here. * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * fix: space count in strings/word_occurrence.py (#1896) * fix: space count in strings/word_occurrence.py * Update strings/word_occurrence.py Co-Authored-By: Christian Clauss <[email protected]> * Update strings/word_occurrence.py Co-Authored-By: Christian Clauss <[email protected]> * Update strings/word_occurrence.py Co-Authored-By: Christian Clauss <[email protected]> * Update word_occurrence.py Seems like, there is no need o `occurrence.pop('', None)` Co-authored-by: Christian Clauss <[email protected]> * Add cellular_automata directory (#1902) Related to https://github.com/TheAlgorithms/Python/issues/1613#issuecomment-618175224 @8Dion8 Your review please. Once this land, this directory would be a great place for you to add your work. * Update linear_search.py (#1906) * Fix typo in Project Euler sol1.py (#1875) * Added sepia tone (#1877) * Add sepia tone * Add unit test * technic --> technique * Update digital_image_processing/sepia.py Co-Authored-By: Christian Clauss <[email protected]> * Update digital_image_processing/sepia.py Co-Authored-By: Christian Clauss <[email protected]> * Fixed errors after commit changes * Fixed errors Co-authored-by: Christian Clauss <[email protected]> * Create one_dimensional.py (#1905) * Create one_dimensional.py * Update cellular_automata/one_dimensional.py Co-Authored-By: Christian Clauss <[email protected]> * Update cellular_automata/one_dimensional.py Co-Authored-By: Christian Clauss <[email protected]> * Update one_dimensional.py Moved import to the top so that the type Image gets recognized * Update one_dimensional.py * Update cellular_automata/one_dimensional.py * Update cellular_automata/one_dimensional.py * Update one_dimensional.py * Update one_dimensional.py * Update one_dimensional.py Co-authored-by: Christian Clauss <[email protected]> * Blacken one_dimensional.py (#1911) * Blacken one_dimensional.py * updating DIRECTORY.md * Travis CI: Upgrade to Ubuntu 20.04 LTS Focal Ubuntu 20.04 LTS (Focal Fossa) https://releases.ubuntu.com/focal Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added A1Z26 Cipher (#1914) * A1Z26 Cipher * A1Z26 Cipher * Added type hints * Added Doctests * removed tabs, spaces instead * corrected doctest * corrected doctest * info URLs added * Condensed decode to one line * Condensed encode function to a single line * Nice one! Co-authored-by: Christian Clauss <[email protected]> * Added Burkes dithering algorithm. (#1916) * Added Burkes dithering algorithm * Added unit tests for burkes algorithm * Fix burkes algorithm * Added some additional information * Fixed CI tests * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <[email protected]> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <[email protected]> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <[email protected]> * Propogate the += and add a doctest * Fix doctest * @staticmethod --> @ classmethod to ease testing * def test_burkes(file_path): * Fix for mypy checks * Fix variable order in get_greyscale * Fix get_greyscale method * Fix get_greyscale method * 3.753 Co-authored-by: Christian Clauss <[email protected]> * Fix invalid escape sequence in binary_search_tree.py (#1920) * Fix invalid escape sequence in binary_search_tree.py data_structures/binary_tree/binary_search_tree.py:156 /home/travis/build/TheAlgorithms/Python/data_structures/binary_tree/binary_search_tree.py:156: DeprecationWarning: invalid escape sequence \ * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Graph coloring (#1921) * add skeleton code * add doctests * add mainc function pseudo code and tests (ToDo: write Implementation) * typo fixes * implement algorithm * add type checking * add wikipedia link * typo fix * update range syntax Co-authored-by: Christian Clauss <[email protected]> * change indexed iteration checking to any() Co-authored-by: Christian Clauss <[email protected]> * fix: swap import and documentation sections * fix: change return none to return empty list * remove unnecessary import (Union) * change: remove returning boolean indicating problem was solved or not * remove unnecessary import (Tuple) Co-authored-by: Christian Clauss <[email protected]> * Add shortest path by BFS (#1870) * Create breadth_first_search_shortest_path.py * updating DIRECTORY.md * Reduce side effect of `shortest_path` For the sake of future testing and documentation - * fixup! Format Python code with psf/black push * Fix typo `separately` * Change to get() from dictionary Co-Authored-By: Christian Clauss <[email protected]> * Move graph to the top * fixup! Format Python code with psf/black push * Add doctest for shortest path * Add doctest for BFS * fixup! Format Python code with psf/black push * Add typings for breadth_first_search_shortest_path * fixup! Format Python code with psf/black push * Remove assert from doctests * Add blank line to doctest Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: John Law <[email protected]> Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: John Law <[email protected]> * Changed the deprecated `np.matrix` to `np.ndarray` (#1923) * Wrap lines that go beyond GitHub Editor (#1925) * Wrap lines that go beyond GiHub Editor * flake8 --count --select=E501 --max-line-length=127 * updating DIRECTORY.md * Update strassen_matrix_multiplication.py * fixup! Format Python code with psf/black push * Update decision_tree.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update stale comment (#1924) * Update close comment * Update stale.yml * Multiline strings in yaml files https://yaml-multiline.info/ Co-authored-by: John Law <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * Hamiltonian Cycle (#1930) * add skeleton code * add doctests * add tests for util function + implement wrapper * full implementation * add ability to add starting verex for algorithm * add static type checking * add doc tests to validation method * bug fix: doctests expected failing * Update hamiltonian_cycle.py * Update hamiltonian_cycle.py Co-authored-by: Christian Clauss <[email protected]> * support_vector_machines.py increase error tolerance to suppress convergence warnings (#1929) * Update support_vector_machines.py * Update support_vector_machines.py Co-authored-by: Christian Clauss <[email protected]> * enhanced segment tree implementation and more pythonic (#1715) * enhanced segment tree implementation and more pythonic enhanced segment tree implementation and more pythonic * add doctests for segment tree * add type annotations * unified processing sum min max segment tre * delete source encoding in segment tree * use a generator function instead of returning * add doctests for methods * add doctests for methods * add doctests * fix doctest * fix doctest * fix doctest * fix function parameter and fix determine conditions * Check if a item exist in stack or not (#1931) * Check if a item exist in stack or not * implemented __contains__ method in stack * made changes in __contains__ * added method for checking armstrong number (#1936) * added method for checking armstrong number * Update comment Co-authored-by: Christian Clauss <[email protected]> * Solution for Euler Problem 26 (#1939) * Solution for Euler Problem 26 * Update project_euler/problem_26/sol1.py typo error fix. Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py typo error fix Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py ok to remove, this comes from Pycharm automatically when docstring is added. Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py ok to remove. Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <[email protected]> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <[email protected]> * now_divide = now_divide * 10 % divide_by_number Co-authored-by: Christian Clauss <[email protected]> * Fix psf/black issues than fail the build (#1935) * Fix psf/black issues than fail the build * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Delete FUNDING.yml * Create sol2.py (#1876) * Create sol2.py * updating DIRECTORY.md * Update DIRECTORY.md * updating DIRECTORY.md * Update sol2.py * Update DIRECTORY.md * updating DIRECTORY.md * Improve docstrings Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: vinayak <[email protected]> Co-authored-by: John Law <[email protected]> * Deal with maps (#1945) * Deal with maps Try with the search term "pizza" to see why this was done in #1932 * fixup! Format Python code with psf/black push * Update armstrong_numbers.py * updating DIRECTORY.md * Update crawl_google_results.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * change method name from front to get_front (#1943) Co-authored-by: “Vipul <“[email protected]”> * Added new algorithm: cracking caesar cipher with the chi-squared test (#1950) * added decrypt_caesar_with_chi_squared.py and ran all checks * Updated default parameters Removed mistake with mutable default arguments Co-authored-by: Christian Clauss <[email protected]> * Updated handling for optional arguments Co-authored-by: Christian Clauss <[email protected]> * Changed return statement to tuple Made function return a tuple instead of a list * Added more doctests * Fixed spelling mistakes * black . - reformatted decrypt_caesar_with_chi_squared.py * Updated if statements to fit the updated code * Minimized amount of lines in the code. Co-authored-by: Christian Clauss <[email protected]> * Added Lstm example for stock predection (#1908) * Added Lstm example for stock predection * Changes after review * changes after build failed * Add Kiera’s to requirements.txt * requirements.txt: Add keras and tensorflow * psf/black Co-authored-by: Christian Clauss <[email protected]> * Added Shortest Job First Algorithm (#1957) * Added Shortest Job First Algorithm It is in IPYNB format but the dataframes are really looking good. Please, take a look. * Delete Shortest_Job_First_Algorithm.ipynb * Added Shortest Job First Algorithm * Update Shortest_Job_First Algorithm.py * Update Shortest_Job_First Algorithm.py * Update Shortest_Job_first Algorithm * Added Shortest_Job_First Algorithm * Added Shortest Job First Algorithm * Update shortest_job_first_algorithm.py * Format code with psf/black Co-authored-by: Christian Clauss <[email protected]> * Add sleep-sort (#1867) * added sleepsort Adding sleepsort * Add doctest and typing for sleepsort * Use self-descriptive variable name * Update sleepsort.py * Update sorts/sleepsort.py Co-authored-by: John Law <[email protected]> Co-authored-by: Christian Clauss <[email protected]> * Add graphs/frequent_pattern_graph_miner.py (#1866) * Add files via upload * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <[email protected]> * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Update frequent_pattern_graph_miner.py * Whitespace changes * Format with psf/black Co-authored-by: Christian Clauss <[email protected]> * Added Nearest neighbour algorithm (#1934) * Upgrades to caesar_cipher.py (#1958) * Added more flexibility to functions, decreased amount of repeating code * Added docstrings * Updated input functions * Added doctests * removed test piece of code * black . * Updated caesar cipher standard alphabet to fit python 3.8 * Update and rename sleepsort.py to sleep_sort.py * Or 4 Co-authored-by: Christian Clauss <[email protected]> * Travis CI: lint for useless backslashes (#1961) * Travis CI: lint for useless backslashes * updating DIRECTORY.md * flake8 --max-complexity=25 Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Kadanes_algorithm (#1959) * Add files via upl…
1 parent 3a77380 commit abe098f

File tree

718 files changed

+41762
-8277
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

718 files changed

+41762
-8277
lines changed

Diff for: .coveragerc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[report]
2+
sort = Cover
3+
omit =
4+
.env/*

Diff for: .github/pull_request_template.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### **Describe your change:**
2+
3+
4+
5+
* [ ] Add an algorithm?
6+
* [ ] Fix a bug or typo in an existing algorithm?
7+
* [ ] Documentation change?
8+
9+
### **Checklist:**
10+
* [ ] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md).
11+
* [ ] This pull request is all my own work -- I have not plagiarized.
12+
* [ ] I know that pull requests will not be merged if they fail the automated tests.
13+
* [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
14+
* [ ] All new Python files are placed inside an existing directory.
15+
* [ ] All filenames are in all lowercase characters with no spaces or dashes.
16+
* [ ] All functions and variable names follow Python naming conventions.
17+
* [ ] All function parameters and return values are annotated with Python [type hints](https://docs.python.org/3/library/typing.html).
18+
* [ ] All functions have [doctests](https://docs.python.org/3/library/doctest.html) that pass the automated testing.
19+
* [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
20+
* [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.

Diff for: .github/stale.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 30
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- bug
8+
- help wanted
9+
- OK to merge
10+
# Label to use when marking an issue as stale
11+
staleLabel: wontfix
12+
# Comment to post when marking an issue as stale. Set to `false` to disable
13+
markComment: >
14+
This issue has been automatically marked as stale because it has not had
15+
recent activity. It will be closed if no further activity occurs. Thank you
16+
for your contributions.
17+
# Comment to post when closing a stale issue. Set to `false` to disable
18+
closeComment: >
19+
Please reopen this issue once you commit the changes requested or
20+
make improvements on the code. Thank you for your contributions.

Diff for: .github/workflows/autoblack.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# GitHub Action that uses Black to reformat Python code (if needed) when doing a git push.
2+
# If all Python code in the repo is compliant with Black then this Action does nothing.
3+
# Otherwise, Black is run and its changes are committed to the repo.
4+
# https://github.com/cclauss/autoblack
5+
6+
name: autoblack_push
7+
on: [push]
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v1 # Use v1, NOT v2
13+
- uses: actions/setup-python@v2
14+
- run: pip install black
15+
- run: black --check .
16+
- name: If needed, commit black changes to a new pull request
17+
if: failure()
18+
run: |
19+
black .
20+
git config --global user.name github-actions
21+
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
22+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
23+
git commit -am "fixup! Format Python code with psf/black push"
24+
git push --force origin HEAD:$GITHUB_REF

Diff for: .github/workflows/codespell.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# GitHub Action to automate the identification of common misspellings in text files
2+
# https://github.com/codespell-project/codespell
3+
name: codespell
4+
on: [push, pull_request]
5+
jobs:
6+
codespell:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-python@v2
11+
- run: pip install codespell flake8
12+
- run: |
13+
SKIP="./.*,./other/dictionary.txt,./other/words,./project_euler/problem_22/p022_names.txt"
14+
codespell -L ans,fo,hist,iff,secant,tim --skip=$SKIP --quiet-level=2

Diff for: .github/workflows/directory_writer.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# The objective of this GitHub Action is to update the DIRECTORY.md file (if needed)
2+
# when doing a git push
3+
name: directory_writer
4+
on: [push]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v1 # v1, NOT v2
10+
- uses: actions/setup-python@v2
11+
with:
12+
python-version: 3.x
13+
- name: Write DIRECTORY.md
14+
run: |
15+
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
16+
git config --global user.name github-actions
17+
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
18+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
19+
- name: Update DIRECTORY.md
20+
run: |
21+
git add DIRECTORY.md
22+
git commit -am "updating DIRECTORY.md" || true
23+
git push --force origin HEAD:$GITHUB_REF || true

Diff for: .github/workflows/stale.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Mark stale issues and pull requests
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
jobs:
6+
stale:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/stale@v1
10+
with:
11+
repo-token: ${{ secrets.GITHUB_TOKEN }}
12+
stale-issue-message: >
13+
Please reopen this issue once you add more information and updates here.
14+
If this is not the case and you need some help, feel free to seek help
15+
from our [Gitter](https://gitter.im/TheAlgorithms) or ping one of the
16+
reviewers. Thank you for your contributions!
17+
stale-pr-message: >
18+
Please reopen this pull request once you commit the changes requested
19+
or make improvements on the code. If this is not the case and you need
20+
some help, feel free to seek help from our [Gitter](https://gitter.im/TheAlgorithms)
21+
or ping one of the reviewers. Thank you for your contributions!
22+
stale-issue-label: 'no-issue-activity'
23+
stale-pr-label: 'no-pr-activity'

Diff for: .gitignore

+26-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
env/
1211
build/
1312
develop-eggs/
1413
dist/
@@ -20,12 +19,14 @@ lib64/
2019
parts/
2120
sdist/
2221
var/
22+
wheels/
2323
*.egg-info/
2424
.installed.cfg
2525
*.egg
26+
MANIFEST
2627

2728
# PyInstaller
28-
# Usually these files are written by a python script from a template
29+
# Usually these files are written by a Python script from a template
2930
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3031
*.manifest
3132
*.spec
@@ -42,8 +43,9 @@ htmlcov/
4243
.cache
4344
nosetests.xml
4445
coverage.xml
45-
*,cover
46+
*.cover
4647
.hypothesis/
48+
.pytest_cache/
4749

4850
# Translations
4951
*.mo
@@ -52,6 +54,7 @@ coverage.xml
5254
# Django stuff:
5355
*.log
5456
local_settings.py
57+
db.sqlite3
5558

5659
# Flask stuff:
5760
instance/
@@ -66,7 +69,7 @@ docs/_build/
6669
# PyBuilder
6770
target/
6871

69-
# IPython Notebook
72+
# Jupyter Notebook
7073
.ipynb_checkpoints
7174

7275
# pyenv
@@ -75,17 +78,32 @@ target/
7578
# celery beat schedule file
7679
celerybeat-schedule
7780

78-
# dotenv
79-
.env
81+
# SageMath parsed files
82+
*.sage.py
8083

81-
# virtualenv
84+
# Environments
85+
.env
86+
.venv
87+
env/
8288
venv/
8389
ENV/
90+
env.bak/
91+
venv.bak/
8492

8593
# Spyder project settings
8694
.spyderproject
95+
.spyproject
8796

8897
# Rope project settings
8998
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# mypy
104+
.mypy_cache/
105+
106+
.DS_Store
90107
.idea
91-
.DS_Store
108+
.try
109+
.vscode/

Diff for: .gitpod.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tasks:
2+
- init: pip3 install -r ./requirements.txt

Diff for: .travis.yml

+13-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1+
os: linux
2+
dist: focal
13
language: python
4+
python: 3.8
25
cache: pip
3-
python:
4-
- 2.7
5-
- 3.6
6-
#- nightly
7-
#- pypy
8-
#- pypy3
9-
matrix:
10-
allow_failures:
11-
- python: nightly
12-
- python: pypy
13-
- python: pypy3
14-
install:
15-
#- pip install -r requirements.txt
16-
- pip install flake8 # pytest # add another testing frameworks later
6+
before_install: pip install --upgrade pip setuptools six
7+
install: pip install -r requirements.txt
178
before_script:
18-
# stop the build if there are Python syntax errors or undefined names
19-
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
20-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
21-
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
9+
- black --check . || true
10+
- IGNORE=E123,E203,E265,E266,E302,E401,E402,E712,E731,E741,E743,F811,F841,W291,W293,W503
11+
- flake8 . --count --ignore=$IGNORE --max-complexity=25 --max-line-length=127 --show-source --statistics
2212
script:
23-
- true # pytest --capture=sys # add other tests here
24-
notifications:
25-
on_success: change
26-
on_failure: change # `always` will be the setting once code changes slow down
13+
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory
14+
- mypy --ignore-missing-imports .
15+
- pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=. .
16+
after_success:
17+
- scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

Diff for: ArithmeticAnalysis/Intersection.py

-16
This file was deleted.

Diff for: ArithmeticAnalysis/LUdecomposition.py

-34
This file was deleted.

Diff for: ArithmeticAnalysis/NewtonMethod.py

-15
This file was deleted.

Diff for: ArithmeticAnalysis/NewtonRaphsonMethod.py

-38
This file was deleted.

0 commit comments

Comments
 (0)