Commit Graph

71 Commits

Author SHA1 Message Date
Du Yuanchao
cbbc43ba3a
Updated problem_04 in project_euler (#2427)
* Updated problem_04 in project_euler

* fixup! Format Python code with psf/black push

* That number is larger than our acceptable range.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-14 22:33:08 +02:00
Du Yuanchao
44b8cb0c81
Updated Stack (#2414)
* * Added type hints
* Added test
* Formated code

* updating DIRECTORY.md

* Update stack.py

* Test error conditions for pop, peek, and

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-13 13:56:03 +02:00
Du Yuanchao
0591968947
Optimization and fix bug (#2342)
* * optimization aliquot_sum
* fix bug in average_median

* fixup! Format Python code with psf/black push

* Update maths/average_median.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-21 14:39:03 +08:00
Du Yuanchao
34294b5641
Update sum_of_digits.py (#2319)
* * support negative number
* add different version

* fixup! Format Python code with psf/black push

* sum(int(c) for c in str(abs(n)))

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-16 20:31:06 +02:00
Tapajyoti Bose
aa46639cbc
Added Kruskal's Algorithm (more organized than the one present) (#2218)
* Added Kruskal's Algorithm

* Added Type Hints

* fixup! Format Python code with psf/black push

* Added Type Hints V2

* Implemented suggestions + uniform naming convention

* removed redundant variable (self.nodes)

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-12 12:16:17 +02:00
Christian Clauss
e49ece95a4
PIL.Image.point() takes an int, not a float (#2284)
* PIL.Image.point() takes an int, not a float

@furkanatesli Trying to remove these warnings from our Travis CI build logs...
https://travis-ci.com/github/TheAlgorithms/Python/builds/178602503#L809

* fixup! Format Python code with psf/black push

* Revert changes to change_brightness.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-07 21:20:56 +02:00
Christian Clauss
23cbe4c352
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>
2020-07-14 13:53:14 +05:30
Christian Clauss
5f4da5d616
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>
2020-07-06 09:44:19 +02:00
Christian Clauss
2c98dce057
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>
2020-07-04 00:56:40 +05:30
vinayak
2d3d660155
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>
2020-07-02 20:02:15 +05:30
Christian Clauss
8ab84fd794
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>
2020-06-25 19:15:30 +02:00
Christian Clauss
5b6ebf8f12
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>
2020-06-23 15:37:24 +02:00
Nika Losaberidze
671e570c35
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>
2020-06-17 18:27:05 +02:00
Nika Losaberidze
fb3a228d26
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>
2020-06-17 18:16:54 +02:00
Nika Losaberidze
2bbdc3bfe7
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>
2020-06-17 18:15:24 +02:00
mateuszz0000
d7a75da8ef
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>
2020-06-17 09:42:44 +02:00
Christian Clauss
f97af65579
Blacken our code (#2125)
* Blacken

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-17 06:59:38 +08:00
Christian Clauss
4e8a0d924e
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>
2020-06-16 16:33:17 +02:00
Christian Clauss
b9e5259aeb
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>
2020-06-16 14:29:13 +02:00
Christian Clauss
b9185bebd6
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>
2020-06-15 09:55:41 +02:00
Nika Losaberidze
8bb7b8f457
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>
2020-06-12 06:51:47 +02:00
mateuszz0000
3de6f010c3
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>
2020-06-11 06:13:40 +02:00
mateuszz0000
1e7df7f77a
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>
2020-06-08 14:11:01 +02:00
Christian Clauss
1e8fe8efcf
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>
2020-05-31 13:06:57 +05:30
Christian Clauss
fa358d614a
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>
2020-05-30 23:47:26 +05:30
Nitisha Bharathi
0e619065e7
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>
2020-05-25 15:10:54 +02:00
Christian Clauss
dc4049ee28
.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>
2020-05-24 20:38:28 +05:30
Christian Clauss
1f8a21d727
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>
2020-05-22 08:10:11 +02:00
Christian Clauss
0e6e5056b3
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>
2020-05-19 13:54:25 +02:00
Kenneth P
77f3888b71
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>
2020-05-18 22:54:08 +02:00
Christian Clauss
38d2e98665
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>
2020-05-18 13:05:51 +02:00
Christian Clauss
565060aa99
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>
2020-05-16 08:49:56 +02:00
Christian Clauss
69171a9ac3
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>
2020-05-13 20:03:28 +02:00
Christian Clauss
a7cd633bb6
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>
2020-05-10 20:49:40 +05:30
Christian Clauss
8b55a143fa
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>
2020-05-09 13:24:25 +02:00
Christian Clauss
08c8bb5ad5
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>
2020-05-06 03:32:40 +02:00
Sanders Lin
1e84aabaea
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>
2020-05-05 17:27:18 +02:00
Christian Clauss
6acd7fb5ce
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>
2020-05-01 23:36:35 +02:00
Sanders Lin
308505f18f
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>
2020-05-01 07:24:32 +02:00
Christian Clauss
8cb957f893
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>
2020-04-27 18:40:46 +02:00
Christian Clauss
24b2aecef3
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>
2020-04-20 20:19:27 +02:00
Sanders Lin
7aaf79cc23
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>
2020-04-17 20:05:29 +02:00
Christian Clauss
d48661e35d
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>
2020-04-17 12:42:00 +02:00
Christian Clauss
f6ee518ee1
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>
2020-04-13 07:50:46 +02:00
Joan Martin Miralles
a38e143cf8
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>
2020-04-07 18:09:05 +02:00
Christian Clauss
ab3400bfad
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>
2020-03-14 23:55:13 +01:00
John Law
2da98db4a7
Effective directory writer (#1800)
* updating DIRECTORY.md

* Update directory_writer.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-03-14 06:37:44 +01:00
matkosoric
7f04e5cd34
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 <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
Christian Clauss
652b891a75
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
2020-02-23 04:23:00 +01:00
Christian Clauss
bef74d0ecc Fix typo (#1718)
* Fix typo

* updating DIRECTORY.md
2020-01-28 05:09:47 +08:00