Meysam
c2a5033f9e
graphs/kruskal: add a test case to verify the correctness, fix styles ( #2443 )
...
* test/graphs/kruskal: adding a test case to verify the correctness of the algorithm
Fixes #2128
* grahps/kruskal: running psf/black
* graphs/kruskal: read edges in a friendlier fashion
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update minimum_spanning_tree_kruskal.py
* fixup! Format Python code with psf/black push
* Update test_min_spanning_tree_kruskal.py
* updating DIRECTORY.md
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-08 20:21:48 +08:00
Dmytro Litvinov
000cedc07f
Add type hints for "strings" folder ( #2882 )
...
* Add type hints for strings/ folder
* Rerun other checks
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-06 14:01:15 +05:30
Iqrar Agalosi Nureyza
e040ad2a01
Add a solution for Project Euler 49 ( #2702 )
...
* added doctests in modular_exponential.py
* added doctests in modular_exponential.py
* added URL link
* updating DIRECTORY.md
* Add problem 49 solution
* updating DIRECTORY.md
* Fix several mistakes
These fixes are intended to follow the CONTRIBUTING.md
* Move the import statements lower
* Update project_euler/problem_49/sol1.py
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-05 08:27:09 +05:30
Richard Wheatley
3b0169549e
Create auto_close_empty_issues.yml ( #2756 )
...
* Create auto_close_empty_issues.yml
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-04 16:20:36 +02:00
Christian Clauss
ddfa9e4f22
Travis CI: Remove redundant tests ( #2523 )
...
* Travis CI: Remove redundant tests
* fixup! before_script
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-30 19:26:38 +02:00
Christian Clauss
db0db01d87
Use self-documenting option instead of cryptic option ( #2487 )
...
* Use self-documenting option instead of cryptic option
@mateuszz0000 Your review, please. Pretend that you do not know what `-L` stands for. How many keystrokes and clicks does it take to confirm the purpose of this option?
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-26 16:54:41 +02:00
Du Yuanchao
18f1dcd48a
Updated singly_linked_list ( #2477 )
...
* Updated singly_linked_list
* fixup! Format Python code with psf/black push
* undo __repr__
* updating DIRECTORY.md
* UNTESTED CHANGES: Add an .__iter__() method.
This will break tests, etc.
* fixup! Format Python code with psf/black push
* len(tuple(iter(self)))
* fixed __repr__()
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update data_structures/linked_list/singly_linked_list.py
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-09-25 16:09:29 +02:00
Du Yuanchao
a1ea76bcf3
Optimization problem_10 in project_euler ( #2453 )
...
* optimization for problem09 in project_euler
* added benchmark code
* fixup! Format Python code with psf/black push
* Update project_euler/problem_09/sol1.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* updating DIRECTORY.md
* Update project_euler/problem_09/sol1.py
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-22 15:15:11 +02:00
Dhruv
ea0759dbaa
Create problem_54 in project Euler ( #2451 )
...
* Add solution and test files for project euler 54
* Update sol1.py
* updating DIRECTORY.md
* Fix: use proper path to open files
* Commit suggestions:
- Use list comprehension instead of map
- Sort imports using isort
* Changes made as suggested (simplified a lot):
- List and set comprehension instead of itemgetter
- Using enumerate as it's easy to read
- Divided into list of card values and set of card suit as set will
remove all the duplicate values. So, no need for double indexing.
- Add test for testing multiple calls to five_high_straight function
* Add suggestions and simplified:
- Split generate_random_hands function into two:
- First will generate a random hand
- Second, which will be called, will return a generator object
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-20 13:52:13 +02:00
Christian Clauss
363858ef3b
hyphen_files = [file for file in filepaths if "-" in file] ( #2447 )
...
* hyphen_files = [file for file in filepaths if "-" in file]
* updating DIRECTORY.md
* Rename recursive-quick-sort.py to recursive_quick_sort.py
* updating DIRECTORY.md
* Rename aho-corasick.py to aho_corasick.py
* updating DIRECTORY.md
* Rename polynom-for-points.py to polynom_for_points.py
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-19 07:13:10 +02:00
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