Commit Graph

3412 Commits

Author SHA1 Message Date
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
kanthuc
d25a926c02
adding static type checking to basic_binary_tree.py (#2293)
* adding static type checking to basic_binary_tree.py

* Add static type checking to functions with None return type

* Applying code review comments

* Added missing import statement

* fix spaciing

* "cleaned up depth_of_tree"

* Add doctests and then streamline display() and is_full_binary_tree()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-11 23:38:38 +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
1fb1fdd130
requirements.txt: Unpin numpy (#2287)
* requirements.txt: Unpin numpy

* fixup! Format Python code with psf/black push

* Less clutter

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-06 17:50:23 +02:00
Sanders Lin
f0d7879a11
fixed error in factorial.py (#1888)
* Update factorial.py

* updating DIRECTORY.md

* Update dynamic_programming/factorial.py

* Update factorial.py

Co-authored-by: mateuszz0000 <mtszzwdzk@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-05 13:18:41 +02:00
Filip Hlasek
871f8f4e00
More efficient least common multiple. (#2281)
* More efficient least common multiple.

* lowest -> least

* integer division

* Update least_common_multiple.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-05 12:39:15 +02:00
Mark
a891f6802a
Procentual proximity scoring algorithm implemented (#2280)
* Procentual proximity scoring algorithm implemented

- added requested changes
- passed doctest

- passed flake8 test

* Apply suggestions from code review

Co-authored-by: Christian Clauss <cclauss@me.com>

* Function rename

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-04 22:11:07 +02:00
Rayvant Sahni
8e7aded87f
World covid19 stats (#2271)
* Josephus problem in Python

Added the code for the josephus problem in python using circular linked lists.

* Update josephus_problem.py

* Added World covid19 stats in web programming

* Delete josephus_problem.py

* Type hints, algorithmic functions should not print

Return a dict of world covid19 stats.  Move all printing into the main functions.

* Update world_covid19_stats.py

* Update world_covid19_stats.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-03 08:45:53 +02:00
TheSuperNoob
b2e8672f02
Fix doubly linked list algorithm (#2062)
* Fix doubly linked list algorithm

* Fix bug with insert_at_tail method

Create __str__() method for Node class and LinkedList class

* Simplify __str__() of LinkedList

Returns empty string if there are no elements in the list

* Fix description
2020-08-02 23:55:18 +08:00
poloso
b875f66f00
Deleted optimization empty directory (#2262) 2020-08-02 06:38:00 +02:00
Sven
1495382367
Fixed bug with incorrect LU decomposition (#2261)
* Fixed Bug #2257

* =

Co-authored-by: Svn-Sp <svn-sp@email>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-01 22:11:39 +02:00
spamegg
473072bd4f
added type hints and doctests to arithmetic_analysis/newton_method.py (#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>
2020-08-01 15:17:46 +02:00
spamegg
9cda130c07
added type hints and doctests to arithmetic_analysis/intersection.py (#2242)
continuing #2128
2020-08-01 08:02:31 +02:00
Prashant Anand
b57b6abb48
fix doctests for recursive binary search (#2229) 2020-08-01 07:26:04 +02:00
Arin Khare
c6c9f4707b
Karger's Algorithm (#2237)
* Add implementation of Karger's Algorithm

* Remove print statement from karger's algorithm function

* Fix style issues in graphs/karger.py

* Change for loops to set comprehensions where appropriate in graphs/karger.py
2020-08-01 09:30:34 +05:30
Christian Clauss
4535283554
Re-blacken (#2246)
* Avoid double spaces

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-01 09:23:23 +05:30
Sumuk Shashidhar
e2ee52d773
removed redundant data_structures folder (#2256) 2020-07-31 20:36:02 +02:00
aryan26roy
373f193c6d
Correcting the Gaussian Formula (#2249)
* Correcting the Gaussian Formula

I have added the parenthesis around the 2*sigma^2 term.

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

* Update gaussian.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-29 21:32:36 +02:00
Utsav Akash Naskar
c7a5f1673e
Python Program to Check Krishnamurthy Number (#2248)
* Added Python Program to Check Perfet Number

* CodeSpell Error Fix - 1

* Build Error Fix - 1

* Made suggested changes

* Use generator expression

* Added Python Program to Check Krishnamurthy Number or not

* Added Python Program to Check Krishnamurthy Number

* Added Python Program to Check Krishnamurthy Number or not

* Build Error Fix - 1

* Build Error Fix - 2

* Fix Brackets positions

* Fix Character Exceeding Error

* Made Review Changes

* Build Error Fix - 3

* Build Error Fix - 4

* Update krishnamurthy_number.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-29 10:54:05 +02:00
lance-pyles
f760ecc73c
initial commit of prefix-conversions (#2243)
* initial commit of prefix-conversions

* minor tweaks;

* Lose the blank lines

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-29 00:11:16 +02:00
Utsav Akash Naskar
9ea144f3bd
Added Python Program to Check Perfect Number (#2244)
* Added Python Program to Check Perfet Number

* CodeSpell Error Fix - 1

* Build Error Fix - 1

* Made suggested changes

* Use generator expression

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-28 09:59:44 +02:00
Palash Sharma
ee282d3687
Update min_heap.py (#2245)
Changed min head to min heap in the first line.
2020-07-28 07:55:35 +02:00
lance-pyles
093a56e3c2
Remove function overhead in area (#2233)
* remove function overhead
add type hints

* remove unused import
2020-07-27 21:29:31 +08:00
spamegg
bd74f20bf2
added type hints and doctests to arithmetic_analysis/bisection.py (#2241)
* 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
2020-07-27 15:23:55 +02:00
Utsav Akash Naskar
dfb4ce4074
Added Finding Exponent Program (#2238)
* Finding Exponent Program

* Build Error Fix - 1

* Build Error Fix - 2

* Error Fix - 1 datatype

* self-documenting naming convension added

* Update and rename exponent_recursion.py to power_using_recursion.py

* Fix typo

* Fix typo

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-27 11:33:13 +02:00
Vasu Gamdha
e296f7b3ff
Updated maths/number_of_digits.py (#2221)
* Updated number_of_digits.py

Added two more methods!

* Update number_of_digits.py

* Update number_of_digits.py

* Added benchmarks!

* Update number_of_digits.py

* Update number_of_digits.py

* Update number_of_digits.py

* Update number_of_digits.py

* Update number_of_digits.py

* Update number_of_digits.py

* Update number_of_digits.py
2020-07-26 12:42:18 +02:00
zakademic
977dfaa46c
Linear algebra/power iteration (#2190)
* Initial commit of power iteration.

* Added more documentation for power iteration and rayleigh quotient

* Type hinting for rayleigh quotient

* Changes after running black and flake8.

* Added doctests, added unit tests. Removed Rayleigh quotient as it is not needed.

* Update linear_algebra/src/power_iteration.py

Changed convergence check line.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update linear_algebra/src/power_iteration.py

Named tests more clearly.

Co-authored-by: Christian Clauss <cclauss@me.com>

* Changed naming in test function to be more clear. Changed naming in doctests to match function call.

* Self running tests

Co-authored-by: Zeyad Zaky <zeyadzaky@Zeyads-MacBook-Pro.local>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-26 10:51:10 +02:00
lance-pyles
44f9fd12c2
added tests (#2234) 2020-07-25 20:58:53 +02:00
lance-pyles
99b40e2a26
add Rankine scale (#2232)
* add Rankine scale
black formatting

* add Wikipedia links

* add optional rounding, default to 2 digits

* fix variable name

* fixed variable name; helps to stage before commiting
2020-07-24 22:55:18 +02:00
RobotGuy999
a823a86a29
Added "Inverse of Matrix" Algorithm (#2209)
* Added "Inverse of Matrix" Algorithm

* Small quotation marks change

* Update inverse_of_matrix.py

* Updated doctests

* Update inverse_of_matrix.py

* Add type hints

* swaped --> swapped

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-23 13:18:17 +02:00
lance-pyles
b3950035a6
update variable names for consistency using standard formula terms; (#2223)
* update variable names for consistency using standard formula terms;

fix flake8 syntax errors;

fix doctests;

* tweak to variable name
2020-07-23 00:49:34 +02:00
ryuta69
9ec71cbdda
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 make python3 prior to python

Co-authored-by: Christian Clauss <cclauss@me.com>

* Fix name of is_surplus into has_last_odd_item

* Add comment

* Fix long comment to shorten

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-20 22:42:08 +05:30
karimzakir02
88e82db89a
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>
2020-07-15 21:30:54 +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
XxSamixX123
749ffd8c6f
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>
2020-07-13 22:18:37 +02:00
KARTHIKEYAN ANBARASU
e292ddb5ec
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>
2020-07-13 09:17:13 +05:30
Kim-R2O
423dd2b020
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>
2020-07-10 17:26:27 +02:00
Dan Murphy
1f1c3b0e4b
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>
2020-07-10 15:36:51 +02:00
Advik Kulkarni
6c2c08c076
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>
2020-07-10 14:56:43 +02:00
David Aaron Banda Gutierrez
05c14c6be8
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>
2020-07-10 10:30:48 +02:00
Hardik Aggarwal
b6ca263983
Update decimal_to_binary.py (#2185)
"an Integer" instead of "a Integer"
2020-07-07 13:26:10 +02:00
D4rkia
aa01114c27
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>
2020-07-07 12:46:09 +02:00
Marcos Cannabrava
728c0df355
Fix typo: Adjancent -> Adjacent (#2184) 2020-07-06 22:00:07 -05:00
wuyudi
367f8ceddd
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>
2020-07-07 00:22:44 +02:00
lance-pyles
48df91d48b
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
2020-07-07 00:21:59 +02:00
Christian Clauss
2c75a7b3dd
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
2020-07-06 19:31:04 +02:00
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
cd3e8f95a0
isort --profile black --recursive . (#2170)
* isort --profile black --recursive .

* Update codespell.yml

* typo: vertices

* typo: Explanation

* typo: Explanation

* Fix typos
2020-07-06 08:48:18 +05:30
Akash Shroff
25d9d819a2
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>
2020-07-05 11:21:32 +02:00
Reinhold
64bef606b6
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>
2020-07-04 11:23:23 +02:00