Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDev sprint ideas: More tests, type hints and less complexity #2128
Comments
We push all new contributions to use type hints as discussed in CONTRIBUTING.md.
We do this already https://github.com/TheAlgorithms/Python/blob/master/.travis.yml#L17 |
@cclauss How about a dev sprint kind of thing where we go about adding all such improvements? |
Cool idea! Another thing (a sprint topic?) that is bugging me is code complexity which we currently set to 25 but I would be much happier to see it at 15. We would need to ensure that the files have strong type hints and tests before modifying them to reduce their cyclomatic complexity. |
Another cool sprint topic would be to add doctests to Python files that have <10% test coverage. Some files like file_transfer/send_file.py and the web programming files are difficult to write tests for but others should be fair game. |
Should we have a short sprint or a long one? One idea would be 24 hour sprint — given that tomorrow is summer solstice (longest day of the year) — the sprint could start at midnight tonight (in whatever timezone the contributer is in) and last for 24 hours. #2128 could be our tracking issue for keeping track of tasks and accomplishments. Thoughts on this Summer Solstice Special Sprint idea. |
Seems awesome, we can gain some attention by Summer Solstice Special Sprint, I am up on gitter if you want to discuss |
Difficult but not impossible. We can create issue with some labels. Perhaps we find someone who will write tests or even code (for example simple server for response) for testing it |
…#2141) * Euler problem 551 sol 1: Reduce McCabe code complexity As discussed in TheAlgorithms#2128 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* hamming_code.py: Reduce McCabe code complexity As discussed in TheAlgorithms#2128 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
I have an idea. How about making the code more idiomatic and Pythonic? For example, currently I see a lot of code of the form: for i in range(len(some_iterable)):
...
do something with i or some_iterable[i] It is better to do: for index, item in enumerate(some_iterable):
...
do something with item or index or if it is a dictionary: for key, value in some_iterable.items():
do something with key or value This is just one example. There are also many pieces of code where comprehension can replace for-loops. There are many other ways to write more Pythonic code. Here are some excellent videos from one of the experts of the subject: I understand this would be a huge undertaking, but it's just an idea that pays off greatly in the long run. We can all become better Python coders! |
Incrementalism wins. Please don't try to do this across many files at once. Instead, please find a file that needs improvement and submit a pull request to improve just that one file. Please create other similar PRs for other individual files. We can progress file-by-file in this manner. |
@cclauss Got it. |
) * added type hints and doctests to arithmetic_analysis/bisection.py continuing in line with #2128 * modified arithmetic_analysis/bisection.py Put back print statement at the end, replaced algorithm's print statement with an exception. * modified arithmetic_analysis/bisection.py Removed unnecessary type import "Optional" * modified arithmetic_analysis/bisection.py Replaced generic Exception with ValueError. * modified arithmetic_analysis/bisection.py fixed doctests
…#2259) * added type hints and doctests to arithmetic_analysis/newton_method.py Continuing #2128 Also changed some variable names, made them more descriptive. * Added type hints and doctests to arithmetic_analysis/newton_method.py added a type alias for Callable[[float], float] and cleaned up the exception handling * added type hints and doctests to arithmetic_analysis/newton_method.py improved exception handling * Update newton_method.py Co-authored-by: Christian Clauss <cclauss@me.com>
Hey, keen to contribute. I am first timer in open source |
removed floating point Fixes: TheAlgorithms#2128
* 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 <1anuppanwar@gmail.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <johnlaw.po@gmail.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <johnlaw.po@gmail.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * Update strings/word_occurrence.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update strings/word_occurrence.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update word_occurrence.py Seems like, there is no need o `occurrence.pop('', None)` Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * Update digital_image_processing/sepia.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Fixed errors after commit changes * Fixed errors Co-authored-by: Christian Clauss <cclauss@me.com> * Create one_dimensional.py (#1905) * Create one_dimensional.py * Update cellular_automata/one_dimensional.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update cellular_automata/one_dimensional.py Co-Authored-By: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update digital_image_processing/dithering/burkes.py Co-Authored-By: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * change indexed iteration checking to any() Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <johnlaw.po@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: John Law <johnlaw@linux.com> * 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 <johnlaw.po@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * Update project_euler/problem_26/sol1.py typo error fix Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_26/sol1.py ok to remove, this comes from Pycharm automatically when docstring is added. Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_26/sol1.py ok to remove. Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_26/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * now_divide = now_divide * 10 % divide_by_number Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <itssvinayak@gmail.com> Co-authored-by: John Law <johnlaw@linux.com> * 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 <“vipulrai8891@gmail.com”> * 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 <cclauss@me.com> * Updated handling for optional arguments Co-authored-by: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <johnlaw.po@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Add graphs/frequent_pattern_graph_miner.py (#1866) * Add files via upload * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * Update graphs/frequent_pattern_graph_miner.py Co-Authored-By: Christian Clauss <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 <cclauss@me.com> * 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 upload * Update Kadane's_algorithm.py * Update and rename Kadane's_algorithm.py to kadanes_algorithm.py * Update kadanes_algorithm.py * Update kadanes_algorithm.py * Update kadanes_algorithm.py * Update kadanes_algorithm.py * Update kadanes_algorithm.py Co-authored-by: Christian Clauss <cclauss@me.com> * Added A* algorithm (#1913) * a* algorithm * changes after build error * intent changes * fix after review * ImportMissmatchError * Build failed fix * doctest changes * doctest changes * Travis CI: Strict flake8 (#1962) * Travis CI: Strict flake8 Turn the screws all the way down. * updating DIRECTORY.md * Switch from flake8 --select to --ignore * Quotes * IGNORE=E123,E203,E265,E266,E302,E401,E402,E712,E731,E741,E743,F811,F841,W291,W293,W503 Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Fix astar (#1966) * Fix astar Single character variable names are old school. * fixup! Format Python code with psf/black push * Tuple * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Add type hints to max_heap.py (#1960) * Max heap implementation * Update max_heap.py * Update max_heap.py * Update max_heap.py * __len__ method added * Update max_heap.py Co-authored-by: halilpython <65048618+halilpython@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Iterative merge sort implementation (#1972) * Added Iterative merge sort * Added iterative merge sorts * Update changes * Add the ability to sort strings Co-authored-by: Christian Clauss <cclauss@me.com> * The new version of flake8 is linting f-strings (#1976) * The new version of flake8 is linting f-strings * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update linear_search.py (#1974) * Update linear_search.py Comment modified in line 17 as Sorting not required in Linear Search * Update linear_search.py Comment modified in line 17 * improved prime number generator to check only up to sqrt(n) instead of n (#1984) * improved prime number generator to check only up to sqrt(n) instead of n * added old version as slow_primes() and named new, faster version primes() * fixed docstring in slow_primes * Add a timeit benchmark * Update prime_numbers.py Co-authored-by: Christian Clauss <cclauss@me.com> * Added file aliquot_sum.py (#1985) * Added file aliquot_sum.py containing a function to find theo * Added parameter type info to aliquot_sum.py * Update maths/aliquot_sum.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update maths/aliquot_sum.py Co-authored-by: Christian Clauss <cclauss@me.com> * Updated code to raise ValueErrors if input is bad * Fixed logical operators * Removed unnecessary import * Updated aliquot_sum.py * fixed formatting * fixed documentation Co-authored-by: Christian Clauss <cclauss@me.com> * actions/setup-python@v2 (#1986) * actions/setup-python@v2 * fixup! Format Python code with psf/black push * Update autoblack.yml * updating DIRECTORY.md * Update codespell.yml Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added strand sort (#1982) * Added strand sort * Review changes * Remove boilerplate code * Fixed flake error: E252 * Added missing return type hint * Add tests and type hints to hill cipher (#1991) * Added tests and type hints to hill cipher * Remove extra >>> * import doctest Co-authored-by: John Law <johnlaw.po@gmail.com> * hill_cipher.py: gcd() -> greatest_common_divisor() (#1997) * hill_cipher.py: gcd() -> greatest_common_divisor() * fixup! Format Python code with psf/black push * import string * updating DIRECTORY.md * Change matrix to array Add more tests Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: John Law <johnlaw.po@gmail.com> * added __len__ function (#1812) * added __len__ function Added a function to count number of nodes in linked list * Updated __len__ method used snake_case instead of camel case * Add tests to __len__() Co-authored-by: Christian Clauss <cclauss@me.com> * change doctest line (#2007) * change doctest line import doctest is not relevant with algorithms. move it under main section. * from doctest import testmod Co-authored-by: Christian Clauss <cclauss@me.com> * Pi digit extraction algorithm (#1996) * added pi digit extraction formula * updating DIRECTORY.md * fixed typo in a comment * updated bbp_formula.py * Update maths/bbp_formula.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update maths/bbp_formula.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update bbp_formula.py * Update and rename bbp_formula.py to bailey_borwein_plouffe.py * updating DIRECTORY.md * calculate * "".join(bailey_borwein_plouffe(i) for i in range(1, 12)) * Update bailey_borwein_plouffe.py * Update bailey_borwein_plouffe.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * consists of area of various geometrical shapes (#2002) * consists of area of various geometrical shapes In this program it consists of various area calculation of different geometrical shapes such as (square,rectangle) and many other shapes. * print(f'Rectangle: {area_rectangle(10, 20)=}') * Update area.py * Areas of various geometric shapes: Co-authored-by: Christian Clauss <cclauss@me.com> * Precision must be a nonnegative integer (#2013) * Precision must be a nonnegative integer * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * refactor: move import pytest line of blockchain algs under "main" section. (#2012) * change doctest line import doctest is not relevant with algorithms. move it under main section. * from doctest import testmod * refactor: move doctest under "main" section * Update diophantine_equation.py * Update modular_division.py Co-authored-by: Christian Clauss <cclauss@me.com> * Easter date gauss algorithm (#2010) * Added gauss easter algorithm * Fixes in easter algorithm * Commit suggestions * singly_linked_list.py: psf/black (#2008) * singly_linked_list.py: psf/black * updating DIRECTORY.md * Update singly_linked_list.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update fast_fibonacci.py (#1889) * Update fast_fibonacci.py * Update fast_fibonacci.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update atbash cipher (doc, doctest, performance) (#2017) * Update atbash * Add benchmark() to quantify the performance improvement Co-authored-by: Christian Clauss <cclauss@me.com> * Graphs : Bidirectional A* (#2015) * implement bidirectional astar * add type hints * add wikipedia url * format with black * changes from review * Graphs : Greedy Best First (#2018) * implement greedy best first * implement Greedy Best First Search * review changes * add doctests * >>> gbf.search() # doctest: +NORMALIZE_WHITESPACE Co-authored-by: Christian Clauss <cclauss@me.com> * Fixes in Bidirectional A* (#2020) * implement bidirectional astar * add type hints * add wikipedia url * format with black * changes from review * fix collision check * Add testmod() * # doctest: +NORMALIZE_WHITESPACE * Codespell: euclidean * Codespell: coordinates * Codespell: traversal * Codespell: remaining Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Tighten up psf/black and flake8 (#2024) * Tighten up psf/black and flake8 * Fix some tests * Fix some E741 * Fix some E741 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added bead sort (#2022) * Added bead sort * Commit suggestion * Added checking before sort * Bead sort only works for sequences of nonegative integers Co-authored-by: Christian Clauss <cclauss@me.com> * Update is_palindrome.py (#2025) * Update is_palindrome.py * Update is_palindrome.py * Reuse s Co-authored-by: Christian Clauss <cclauss@me.com> * Merge sort Update variable names (#2032) * Update Merge sort variable names * Update mergesort.py * Update mergesort.py * black * Update mergesort.py Co-authored-by: Christian Clauss <cclauss@me.com> * .travis.yml: Revert to using autoblack (#2033) * .travis.yml: Revert to using autoblack Our autoblack GitHub Action will get us to black compliance without forcing each contributor to learn about, install, and use psf/black on every pull request. * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Euclidean recursive method + doctests + type hints (#1999) * Recursive euclidean algorithm + doctests and type hints * Fix doctests in recursive method * Added commit suggestions * added Boruvka's MST algorithm (#2026) * added Boruvka's MST algorithm * Add files via upload * fixup! Format Python code with psf/black push * Updated Boruvka with doctest * updating DIRECTORY.md * Update minimum_spanning_tree_boruvka.py * No blank line in doctest * <BLANKLINE> * Avoid mutable default values https://docs.python-guide.org/writing/gotchas/ * Update minimum_spanning_tree_boruvka.py * Avoid mutable default values * fixup! Format Python code with psf/black push * Update minimum_spanning_tree_boruvka.py * Update minimum_spanning_tree_boruvka.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Enhance shell sort syntax (#2035) * Created weatherforecast.py (#2037) * Created weatherforecast.py Added weatherforecast.py to retrieve weather information of a location and return dictionary values. * Update weatherforecast.py * Update and rename weatherforecast.py to current_weather.py Co-authored-by: Christian Clauss <cclauss@me.com> * current_weather, weather_forecast, weather_onecall (#2048) * current_weather, weather_forecast, weather_onecall * updating DIRECTORY.md * weather_forecast("Kolkata, India") Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Jaro winkler (#2041) * Added jaro_winkler first version * Added doctests * Fix flake warnings * Refactor * Fixes bug in jaro winkler implementation * Commit suggestions * Missing comming suggestions * Remove unused math module * Import doctest Co-authored-by: John Law <johnlaw.po@gmail.com> * circular_linked_list: Add more len() tests (#2051) * circular_linked_list: Add more len() tests * fixup! Format Python code with psf/black push * prepend() * updating DIRECTORY.md * Fix decrementation of self.length * Add empty list tests Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * data_structures/linked_list: Add __len__() function and tests (#2047) * Update __init__.py please add a function to get length of linked list * Update __init__.py * Update doubly_linked_list.py all size function lo doubly linked list class * prime number _better method * comments * Updated init.py 2 made it more pythonic * updated length function * commnet in linked_list construtor * Update data_structures/linked_list/__init__.py accepecting changes Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/linked_list/__init__.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update __init__.py * Revert changes to doubly_linked_list.py * Revert changes to prime_check.py Co-authored-by: Christian Clauss <cclauss@me.com> * Naive string doctests + typehints (#2054) * Added doctests * Added __main__ * Commit suggestion * Undo changes to keep only doctests and typehints * Reundo function name with params * Update naive_string_search.py * Update naive_string_search.py * Update naive_string_search.py * Update naive_string_search.py Co-authored-by: Christian Clauss <cclauss@me.com> * Create number_of_digits.py (#1975) * Create number_of_digits.py A python program to find the number of digits in a number. * Update number_of_digits.py * Update number_of_digits.py * Add #1976 to get Travis CI to pass #1976 * Add type hints as discussed in CONTRIBUTING.md Co-authored-by: Christian Clauss <cclauss@me.com> * Doctests + typehints in cocktail shaker sort (#2061) * Doctests in cocktail shaker sort * import doctest * print(f"{cocktail_shaker_sort(unsorted) = }") Co-authored-by: John Law <johnlaw.po@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com> * conversions/decimal_to_binary.py: Add type hints (#2001) * A .py file to covert a base to any new base(2-18) * Update base_changer.py * Added type-hints. * Delete base_changer.py * Update build_directory_md.py (#2066) Propagate argument `top_dir` to good_file_paths. Previously this argument did not get passed to the helper function when calling print_directory_md. * create sum_of_digits.py (#2065) * create sum_of_digits.py create sum_of_digits.py to find the sum of digits of a number digit_sum(12345) ---> 15 digit_sum(12345) ---> 10 * Update sum_of_digits.py * Update maths/sum_of_digits.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update maths/sum_of_digits.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update sum_of_digits.py Co-authored-by: Christian Clauss <cclauss@me.com> * Harris corner detection (#2064) * 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 * haris corner detection * fixup! Format Python code with psf/black push * changes after review * changes after review * fixup! Format Python code with psf/black push Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Refactor cycle_sort (#2072) * Refactor cycle_sort * Undo changes to keep only doctests * Remove boilerplate comments and unused variables (#2073) * Errors notifications under pull requests (#2081) * Added error comments under pull requests * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Create-Add files to greedy_method directory (#2082) * Add Greedy Method Approach * Update Filename * Update Variable and Links * Fixed flake8 bugs * Update unittest filename * Update unittest filename * Final unittest filename update * Pythonic Code formatting * flake8 fixes * lowercase function name * Add zip function * Add zip function * params lowercase * Travis CI fixes * Update and rename knapsack_problem.py to knapsack.py * Update test_knapsack.py * Fix bugs * Rename knapsack.py to greedy_knapsack.py * Update test_knapsack.py Co-authored-by: Christian Clauss <cclauss@me.com> * Added travis notifications only on fail (#2091) * Added travis notifications only on fail * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added Readme for computer vision (#2075) * Create README.md * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Refactor remove duplicates to more pythonic (#2093) * Refactor strings/remove_duplicate to more pythonic * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * calc_profit always returns an int (#2090) * calc_profit always returns an int * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * fix fetch_github_info __main__ bug (#2080) * fix fetch_github_info __main__ bug * Algorithms should not print * Update fetch_github_info.py * Update fetch_github_info.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: John Law <johnlaw.po@gmail.com> * Added function to convert from decimal to another base (#2087) * Added function to convert from decimal to another base * Update conversions/decimal_to_any.py Changed type() to isinstance() Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Changed to base in (0, 1) Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Updated to div not in (0, 1) Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Updated to make condition clearer Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Using divmod() instead of % operator Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Improved readability on a docstring test Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Changed use of type() to isinstance() Co-authored-by: Christian Clauss <cclauss@me.com> * Update conversions/decimal_to_any.py Changed from use of type() to isinstance() Co-authored-by: Christian Clauss <cclauss@me.com> * Made changes and improved function * Update conversions/decimal_to_any.py Added space to docstring test Co-authored-by: Christian Clauss <cclauss@me.com> * Changed action for bad input * Added support for conversions up to base 36 (#2087) * Added support for conversions up to base 36 and renamed HEXADECIMAL dict (#2087) * Fixed whitespace issue (#2087) * Fixed issue with line length (#2087) * Fixed issue with conversions past base-10 failing (#2087) * Added more robust testing (#2087) Co-authored-by: Christian Clauss <cclauss@me.com> * created perfect_cube.py (#2076) * created perfect_cube.py To find whether a number is a perfect cube or not. * Update perfect_cube.py * Update perfect_cube.py * Update perfect_cube.py * Add Z-function algorithm implementation (#2067) * Add Z-function algorithm implementation * Spelling correction * Reference url correction * Add additional function as an example of z-function usage, change docstrings for functions * Fix flake8 errors * Update z_function.py Co-authored-by: Christian Clauss <cclauss@me.com> * implement sdbm hash algorithm (#2094) * implement sdbm hash algorithm * fix bug: styling * fix styling for decimal_to_any * Fix syntax for flake8 passing (#2096) * Fix syntax for flake8 passing * fixup! Format Python code with psf/black push * # fmt: off / # fmt: on * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Fix indentation (#2097) * Hash adler32 (#2111) * implement hash * fix indentation * Create natural_language_processing (#2116) * Create natural_language_processing Closes #2115 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * implement rat in maze algorithm. (#2106) * implement rat in maze algorithm. * style changes * fix trailing whitespace * add test, fix style * fix style * method change * minor changes * style changes * return solved Co-authored-by: Christian Clauss <cclauss@me.com> * Fix line break after binary operator (#2119) * Fix line break after binary operator * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Add pytest init file to define custom mark mat_ops (#2120) Fixes #1917. * Set the Python file maximum line length to 88 characters (#2122) * flake8 --max-line-length=88 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Fix long line, tests (#2123) * Fix long line * updating DIRECTORY.md * Add doctest * ... * ... * Update tabu_search.py * space * Fix doctest >>> find_neighborhood(['a','c','b','d','e','a']) # doctest: +NORMALIZE_WHITESPACE [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90], ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: John Law <johnlaw.po@gmail.com> * Count (#2084) * Add files via upload * Update and rename count_islands.py to count_islands_in_matrix.py * Update matrix/count_islands_in_matrix.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/count_islands_in_matrix.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/count_islands_in_matrix.py Co-authored-by: Christian Clauss <cclauss@me.com> * Reformat count islands.py * Indent Python code with 4 spaces, not tabs * Update count_islands_in_matrix.py * Add type hints for return values Co-authored-by: Christian Clauss <cclauss@me.com> * CONTRIBUTING.md: Update flake8 command (#2124) * CONTRIBUTING.md: Update flake8 command * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Graphs : Bidirectional Breadth-First Search (#2057) * implement bidirectional breadth first * remove useless import * remove trailing whitespaces * implementation of entropy algorithm. (#2110) * implementation of entropy algorithm. * add tests, fix requested changes * open_file() --> analyze_text() * Create bidirectional_breadth_first_search.py * # type: ignore Co-authored-by: Christian Clauss <cclauss@me.com> * Hash djb2 (#2098) * implement hash * fix flake8 error * Update hashes/djb2.py * Update hashes/djb2.py * Long lines * def djb2(s: str) -> int: Co-authored-by: Christian Clauss <cclauss@me.com> * Blacken our code (#2125) * Blacken Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Create change_brightness.py (#2126) * Create change_brightness.py * Update change_brightness.py * Update change_brightness.py * Update change_brightness.py * Update change_brightness.py Co-authored-by: Christian Clauss <cclauss@me.com> * Added doctests to bucket sort (#2079) * Added doctests to bucket sort * Missing typehint * Wrap long lines * updating DIRECTORY.md * Update bucket_sort.py * updating DIRECTORY.md * Update bucket_sort.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added maximum non-adjacent sum (#2130) * Added maximum non-adjacent sum * Bugfix: flake8 test * Implemented changes (broke tuple unpacking into 2 lines due to flake8 tests) * Implemented changes v2.0 * Update max_non_adjacent_sum.py Co-authored-by: Christian Clauss <cclauss@me.com> * Implement connected components algorithm for graphs (#2113) * Implement connected components algorithm for graphs * fixup! Format Python code with psf/black push * Add parameters and return values annotations with Python type hints * updating DIRECTORY.md * Add doctests and typehints * Remove unnecessary comments, change variable names * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Strongly connected components (#2114) * Implement strongly connected components for graph algorithms * fixup! Format Python code with psf/black push * Delete trailing whitespace * updating DIRECTORY.md * Add doctests and typehints * Remove unnecessary comments, change variable names * fixup! Format Python code with psf/black push * Change undefined variable's name * Apply suggestions from code review Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Implement prefix function, knuth-morris-pratt another usage (#2099) * Implement prefix function, knuth-morris-pratt another usage * fixup! Format Python code with psf/black push * Fix style * updating DIRECTORY.md * Update prefix_function.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Add lempel ziv compression (#2107) * Added lempel-ziv compression algorithm implementation * Added lempel-ziv decompression algorithm implementation * Reformatted lempel-ziv compress/decompress files using black * Added type hints and some other modifications (Doctests coming up) * Shortened several lines to comply with the standards * Added (Open) Knight Tour Algorithm (#2132) * Added (Open) Knight Tour Algorithm * Implemented Suggestions * add visualization of k means clustering as excel format (#2104) * add visualization of kmneas clust as excel format * style changes * style changes * Add doctest and typehint! * style change * Update machine_learning/k_means_clust.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/k_means_clust.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Euler problem 551 sol 1: Reduce McCabe code complexity (#2141) * Euler problem 551 sol 1: Reduce McCabe code complexity As discussed in #2128 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * hamming_code.py: Reduce McCabe code complexity (#2140) * hamming_code.py: Reduce McCabe code complexity As discussed in #2128 * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added Markov Chain (#2146) * Added Markov Chain * Implemented suggestions * Add doctests to radix_sort() (#2148) * Add doctests to radix_sort() * fixup! Format Python code with psf/black push * Update radix_sort.py * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added doctests to OddEvenTraposition (#2152) * Added doctests * Change __main__ content * Typehints + refactor (#2154) * Update avl_tree.py (#2145) * Update avl_tree.py it's true definition of AVL tree,change left and right rotation,and add avl_tree doctest * Update avl_tree.py * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update data_structures/binary_tree/avl_tree.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update avl_tree.py update some function name and update doctest * Update avl_tree.py change some code format to fit flake8 review Co-authored-by: Christian Clauss <cclauss@me.com> * NLP Word Frequency Algorithms (#2142) * NLP Word Frequency Algorithms * Added type hints and Wikipedia link to tf-idf * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Fix line length for flake8 * Fix line length for flake8 V2 * Add line escapes and change int to float * Corrected doctests * Fix for TravisCI * Fix for TravisCI V2 * Tests passing locally * Tests passing locally * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update machine_learning/word_frequency_functions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Add doctest examples and clean up docstrings Co-authored-by: Christian Clauss <cclauss@me.com> * Added LRU Cache (#2138) * Added LRU Cache * Optimized the program * Added Cache as Decorator + Implemented suggestions * Implemented suggestions * Added LFU Cache (#2151) * Added LFU Cache * Update lfu_cache.py * None is returned * Add type hints Co-authored-by: Christian Clauss <cclauss@me.com> * project_euler/problem_47/sol1.py (#2150) * Create __init__.py * Initial commit Not sure if this should be formatted differently. I'm open to ideas! * Completing testing/updates Ran code through `black`, `flake8`, and `doctest`. Added some type hints. `doctest` is finicky on sets, so I had to sort and reformat as set to pass those tests. * Update project_euler/problem_47/sol1.py Nice. Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Looks good Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Okay, this should work. Thank you for the reminder on map(), filter(), reduce(). Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py My IDE needs a spellchecker. Or, lighter comment font. Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py This means that `results = run(N)` should be updated to `results = run(n)`, correct? Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Looks good! Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update project_euler/problem_47/sol1.py Works for me! I spent way too much time getting this to pass doctest, so any improvement is welcome. Co-authored-by: Christian Clauss <cclauss@me.com> * Update sol1.py Added some suggested changes from the pull request: * Updated tests outputs in `unique_prime_factors` function. * Changed `@lru_cache(maxsize=5)` to `@lru_cache(maxsize=None)` * Removed duplicate `return` line in `equality` function * Changed `i` to `base` in run function. * Added some commentary to `run()` function. * Replaced `group = list(map(lambda x: base + x, [i for i in range(n)]))` with `group = [base + i for i in range(n)]` * Update sol1.py * Trailing whitespace * Update sol1.py * Update __init__.py * Update sol1.py * Update __init__.py Co-authored-by: Christian Clauss <cclauss@me.com> * Add url and typing hint for BFS (#2156) * Add typing for bfs * Add url for BFS * rename the function Co-authored-by: Christian Clauss <cclauss@me.com> * Update graphs/bfs.py Co-authored-by: Christian Clauss <cclauss@me.com> * Change the return value type of bfs * change the function name. change all instances of bfs() to breadth_first_search(). * change the function name in annotate * Add one more blank line. * Delete one blank line. * Delete one blank line. I've read the https://www.flake8rules.com/rules/W391.html, and still don't know how to do it. I've tried using 0 ,1,2 blank lines... * Update graphs/bfs.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update graphs/bfs.py Co-authored-by: Christian Clauss <cclauss@me.com> * Rename bfs.py to breadth_first_search_2.py Co-authored-by: Christian Clauss <cclauss@me.com> * Only one carriage return (#2155) * updating DIRECTORY.md * touch * fixup! Format Python code with psf/black push * Update word_frequency_functions.py * updating DIRECTORY.md * Update word_frequency_functions.py * Update lfu_cache.py * Update sol1.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Added minimum cost path algorithm (#2135) * Added maximum path sum for matrix (top left to bottom right) * Changed maximum cost path to minimum cost path + added video explaination * black fixes and Travis CI fixes (#2160) * black format * updating DIRECTORY.md * fixes * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Add round_robin scheduling algorithm (#2158) * round_robin and priority cpu scheduling algorithms * Delete priority_cpu_scheduling.py * Delete round_robin_algorithm.py * [add] cpu_scheduling_algorithms * [add] Round robin cpu scheduling algorithm * Update scheduling/round_robin_scheduling_algorithm.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update scheduling/round_robin.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update scheduling/round_robin_scheduling.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update scheduling/round_robin_scheduling.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update scheduling/round_robin.py Co-authored-by: Christian Clauss <cclauss@me.com> * Round_Robin * Update round_robin.py * Update round_robin.py * Update round_robin.py * Update round_robin.py Co-authored-by: pawanbuddy <46370996+pawanbuddy@users.noreply.github.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Rename shortest_job_first_algorithm.py to shortest_job_first.py (#2164) * Rename shortest_job_first_algorithm.py to shortest_job_first.py * updating DIRECTORY.md * Minor tweek to round_robin.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Update matrix_operation.py (#2159) * Update matrix_operation.py * Update matrix_operation.py * Update matrix_operation.py * use yapf to format the code * recover the error check * add typing hint * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * add float doctest * black formated * Update searching_in_sorted_matrix.py * recover this file * f-string, typing hint , doctest * Update matrix_operation.py * Update searching_in_sorted_matrix.py * Update matrix_operation.py * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: vinayak <itssvinayak@gmail.com> * black (#2166) * black * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> * flake8 error fix * Remove unreachable code * union Co-authored-by: Christian Clauss <cclauss@me.com> * double_linear_search algorithm (#2161) * linear search iterating from both array sides * Update double_linear_search.py * Update double_linear_search.py * added doctests * updated doctests * Update double_linear_search.py * Update double_linear_search.py * added blank after >>> * made all the requested changes * Update double_linear_search.py * Update double_linear_search.py Co-authored-by: Christian Clauss <cclauss@me.com> * Gale Shapley Algorithm (#2100) * Gale Shapley Algorithm Implementation of a Nobel prize-winning algorithm that determines a stable matching in a bipartite graph. * Update graphs/gale_shapley_bigraph.py Co-authored-by: Christian Clauss <cclauss@me.com> * Fixed some flake8 issues. * Updated it to donors and recipients * description changes Co-authored-by: Christian Clauss <cclauss@me.com> * description changes Co-authored-by: Christian Clauss <cclauss@me.com> * description changes Co-authored-by: Christian Clauss <cclauss@me.com> * Edited the line lengths * Update gale_shapley_bigraph.py * Update gale_shapley_bigraph.py Co-authored-by: Christian Clauss <cclauss@me.com> * isort --profile black --recursive . (#2170) * isort --profile black --recursive . * Update codespell.yml * typo: vertices * typo: Explanation * typo: Explanation * Fix typos * isort --profile black . (#2181) * updating DIRECTORY.md * isort --profile black . * Black after * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * Numerous fixes to directed_and_undirected_(weighted)_graph.py (#2182) * Numerous fixes to directed_and_undirected_(weighted)_graph.py * dict.keys() is almost never need in modern Python * Add surface area class (#2183) * add surface area class * add new line to end of file * move surface area class into area class * add missing import * added pi import * fix typo * added blank line * fixed more import issues * comment fix * comment fixes * enhance the ability of add (#2178) * enhance the ability of add * Update matrix_operation.py * Update matrix_operation.py * Update matrix_operation.py * Update matrix/matrix_operation.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: Christian Clauss <cclauss@me.com> * Fix typo: Adjancent -> Adjacent (#2184) * Add a missing "genetic algorithm" folder with a basic algorithm inside (#2179) * Add a basic genetic algorithm * Update basic_string.py * Improve comments and readability * Add url to wikipedia * Remove newline Co-authored-by: Christian Clauss <cclauss@me.com> * Sort import Co-authored-by: Christian Clauss <cclauss@me.com> * Apply suggestions from code review Co-authored-by: Christian Clauss <cclauss@me.com> * Improve Comments and readability * Update basic_string.py * Improve logic and efficiency * Add doctest * Update basic_string.py * Update basic_string.py * Update basic_string.py * Apply suggestions from code review Co-authored-by: Christian Clauss <cclauss@me.com> * Update basic_string.py * Update basic_string.py * Update basic_string.py Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: vinayak <itssvinayak@gmail.com> * Update decimal_to_binary.py (#2185) "an Integer" instead of "a Integer" * N queens math (#2175) * add new file for another solution to the n queens problem * Add the code for the algorithm, add comments and add at the top a general explanation * Update backtracking/n_queens_math.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update backtracking/n_queens_math.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update backtracking/n_queens_math.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update backtracking/n_queens_math.py Co-authored-by: Christian Clauss <cclauss@me.com> * No newline at the end of the file * Type hints * whitespaces fixed * Fixed whitespaces * Add type hints * CodeSpell fixed * update * All changes made except changing the board variable to local * Add doctest * Update * Update * Update * Update n_queens_math.py Co-authored-by: Christian Clauss <cclauss@me.com> * sum_of_geometric_progression (#2168) * Add files via upload * Rename sum_of_Geometric_Progression.py to sum_of_geometric_progression.py * Update sum_of_geometric_progression.py * Update maths/sum_of_geometric_progression.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update maths/sum_of_geometric_progression.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update maths/sum_of_geometric_progression.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update sum_of_geometric_progression.py * Update sum_of_geometric_progression.py * Type hints and test for zeros and negative numbers * Update sum_of_geometric_progression.py Co-authored-by: Christian Clauss <cclauss@me.com> * Added Normalization and Standardization Algorithms (#2192) * Added Standardization and Normalization algorithms with built-in stats * Implement ndigits for rounding Co-authored-by: Christian Clauss <cclauss@me.com> * added daily horoscope scrapper script (#2167) * added daily horoscope scrapper * Update daily horoscope scrapper script code refactoring, script editing * Update web_programming/daily_horoscope.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update basic_graphs.py (#1990) * Update basic_graphs.py missing return statement line no:223. * Update basic_graphs.py Co-authored-by: vinayak <itssvinayak@gmail.com> * Added a binomial distribution formula calculator algorithm (#2197) * Add files via upload * Update binomial_distribution.py * Update maths/binomial_distribution.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update binomial_distribution.py * Update maths/binomial_distribution.py Co-authored-by: Christian Clauss <cclauss@me.com> * Update binomial_distribution.py * Update binomial_distribution.py * Update binomial_distribution.py * Update binomial_distribution.py * Update binomial_distribution.py Co-authored-by: Christian Clauss <cclauss@me.com> * black matrix_operation.py (#2199) * black matrix_operation.py * updating DIRECTORY.md * Update matrix_operation.py Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: vinayak <itssvinayak@gmail.com> * Celsius to Fahrenheit Conversions (#2188) * added conversions between celsius and fahrenheit * Renamed celsius_to_fahrenheit.py * Fixed spelling issues * modified file to fit the 88-character limit * added changes to pass the travis-ci test * further changed the files to pass the travis-ci test * further changed the files to pass the travis-ci test * Shortened conversions/fahrenheit_to_celsius.py Co-authored-by: Christian Clauss <cclauss@me.com> * Type hints added to conversions/fahrenheit_to_celsius.py Co-authored-by: Christian Clauss <cclauss@me.com> * changed the code to let the caller do the printing * addressed the changes made on github * Added Kelvin conversions and put temperature functions in a single file * Removed whitespace from a blank line * Update temperature_conversions.py Co-authored-by: Christian Clauss <cclauss@me.com> * Add merge insertion sort (#2211) * Add merge insertion sort * Fix python naming conventions * Add wikipedia link * Add type hint * Fix python to python3 Co-authored-by: Christian Clauss <cclauss@me.com> * Refactor doubled process in if-condition into one outside of if-condition Co-authored-by: Christian Clauss <cclauss@me.com> * Refactor ma…
also modified the main script to be testable I also had to change the line that handled `delete` section Fixes TheAlgorithms#2128
also modified the main script to be testable I also had to change the line that handled `delete` section Fixes TheAlgorithms#2128
currently, some of the programs use static type checking like this program but some of the programs did not use static typing.
it's a good practice to use static typing as it makes code more clear and readable, should we make it a standard for this repository.we can use mypy for testing code
more on static typing
thank you
Dev sprint ideas:
flake8 --max-complexity=15
(Ensure files have strong tests before refactoring). Test results from #2139...