Commit Graph

214 Commits

Author SHA1 Message Date
Christian Clauss
74f4967126
Fix comment (#5742)
* Fix comment

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-01 18:07:47 +01:00
Edward Nuno
94f38dd88c
[mypy] Fix type annotations for linked_stack.py (#5576)
* Fix type annotations for linked_stack.py

* Replace Optional with inline union type

* Rename linked_stack to stack_with_singly_linked_list

* Rename stack_using_dll to stack_with_doubly_linked_list

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-31 17:03:03 +01:00
poloso
61e1dd27b0
[mypy] Fix type annotation in euler_method.py (#5649)
* [mypy] Fix type annotation in euler_method.py

In line with issue #4052.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-28 22:31:32 +02:00
Naveen Namani
11a15cc584
Add solution for Project Euler problem 67 (#5519)
* New solution for Euler problem 67

A faster and memory efficient solution based on the template of sol1.py.
Modified the solution to be more memory efficient while reading and generating the array
and during the solution finding.
No conditions and straightforward logic.

* added return type hint

* Update project_euler/problem_067/sol2.py

Preferring comprehensions over map

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

* Update sol2.py

Self explanatory variable names

* Updated sol2 to problem 067 in directory

* Update project_euler/problem_067/sol2.py

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

* Update project_euler/problem_067/sol2.py

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

* Fixed extra line

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-28 19:27:14 +02:00
Christian Clauss
477cc3fe59
Add pyupgrade to pre-commit (#5638)
* Add pyupgrade to pre-commit

* Remove unused imports

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-28 16:45:59 +02:00
Prakhar Gurunani
329feb4928
Add Project Euler Problem 078 solution 01 (#5565)
* Create sol1.py

* updating DIRECTORY.md

* Create __init__.py

* Add docstring

* Reformat with black

* Fix flake8 issues

* Add EOL

* Fix formatting issues

* Add docstring

* Add func return type

* Change return type

* Remove test print statement

* Reformat code

* Fix return types

* Break loop

* Update doctest sol

* Update project_euler/problem_078/sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Added doctest and changed return type

* Add int()

* Fix flake8 issues

* Use argument instead of fixed constant

* Update sol1.py

* fix sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-27 17:19:04 +08:00
Christian Clauss
cb4dc19723
Financial: principle -> principal (#5614)
* Financial: principle -> principal

The originally invested amount of money: `principal`
-- https://www.grammarly.com/blog/principle-principal/

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-27 00:41:32 +08:00
Prakhar Gurunani
827b8f04a4
Get top 10 HN posts (#5604)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Create get_top_hn_posts.py

* updating DIRECTORY.md

* Add return type and desc

* Add texttable

* Update web_programming/get_top_hn_posts.py

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

* Update web_programming/get_top_hn_posts.py

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

* Get top 10 posts

* Update get_top_hn_posts.py

* Don't use texttable

* Setup doctest

* Fix pre-commit issues

* Remove print statement

* Add hackernews_top_stories_as_markdown()

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-26 15:13:23 +02:00
Christian Clauss
366a0f1839
Fix validate_initial_digits of credit_card_validator.py (#5600)
* Fix validate_initial_digits of credit_card_validator.py

@Bhargavishnu I think that I broke the logic of validate_initial_digits which should require that credit_card_number[0] is 3 before checking that credit_card_number[1] is 4, 5, or 7.  Please verify the new changes and the new test cases to make sure that this is correct.  Thanks!

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-26 14:32:34 +02:00
Prakhar Gurunani
f93c7d4d80
Get user tweets (#5593)
* updating DIRECTORY.md

* Create get_user_tweets.py

* updating DIRECTORY.md

* Reformat code with black

* Add argument type

* Add return type

* Add tweepy

* Fix isort issues

* Fix flake8 issues

* WIP: doctest

* Doctest setup and format with pre-commit

* Remove doctests

* Update web_programming/get_user_tweets.py

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

* Update get_user_tweets.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-26 10:05:13 +02:00
Francisco Perez
568c107e68
add bin_to_hexadecimal (#5156) 2021-10-25 15:58:24 +08:00
Christian Clauss
bd9464e4ac
mandelbrot.py: Commenting out long running tests (#5558)
* mandelbrot.py: Commenting out long running tests

* updating DIRECTORY.md

* Comment out 9 sec doctests

* Update bidirectional_breadth_first_search.py

* Comment out slow tests

* Comment out slow (9.15 sec) pytests...

* # Comment out slow (4.20s call) doctests

* Comment out slow (3.45s) doctests

* Update miller_rabin.py

* Update miller_rabin.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-23 18:15:30 +02:00
Sherman Hui
629848e372
[mypy] Fix type annotations in data_structures/binary_tree (#5518)
* fix: fix mypy errors

Update binary_search_tree `arr` argument to be typed as a list
within `find_kth_smallest` function

Update return type of `merge_two_binary_trees` as both inputs can
be None which means that a None type value can be returned from
this function

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-22 16:07:05 +02:00
John Law
c0acfd46cb
Fix factorial issues (#5496)
* updating DIRECTORY.md

* pass integer to `math.factorial` in `project_euler/problem_015`

* remove duplicated factorial function

* updating DIRECTORY.md

* Update maths/factorial_iterative.py

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

* Update factorial_iterative.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-21 15:06:32 +08:00
Christian Clauss
f7804334f1
length_conversion.py: Deal with uppercase and abbreviations (#5433)
* length_conversion.py: Deal with uppercase and abbreviations

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 11:11:49 +02:00
Christian Clauss
aa0ace4df7
Remove exception detail from doctest (#5430)
* Remove exception detail from doctest

These details are configuration dependant so should be removed according to https://docs.python.org/3/library/doctest.html

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 08:05:20 +02:00
John Law
4bf2eedd3c
[mypy] fix mypy error in Project Euler Problem 092 solution 1 (#5357)
* fix mypy error

* updating DIRECTORY.md

* simplify code

* run black

* fix doc consistency

* Fix doc

* fix doc

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-17 08:07:45 +02:00
Christian Clauss
8dc7cdbc57
Add tests to morse_code.py (#5337)
* Add tests to morse_code.py

@dhruvmanila @poyea Your reviews, please.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-16 18:57:38 +02:00
Christian Clauss
ca842b4add
It is OK to test ./scripts (#5290)
* It is OK to test ./scripts

* updating DIRECTORY.md

* Update build.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-14 18:19:47 +02:00
poloso
9586a6a98e
Change comments for improved consistency (#5223)
* Change comments for improved consistency

https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L56
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L80
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L87

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-12 00:44:38 +08:00
Christian Clauss
15d1cfabb1
from __future__ import annotations (#4763)
* from __future__ import annotations

* updating DIRECTORY.md

* from __future__ import annotations

* from __future__ import annotations

* Update xor_cipher.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-22 23:11:51 +02:00
Christian Clauss
dc07a85076
Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py (#4665)
* Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py

New test cases that the algorithm must detect:
* [ ] an octet much bigger than 255
* [ ] an octet is negative
* [ ] number of octets is less than 4
* [ ] number of octets is greater than 4
* [ ] an octet is a letter

* updating DIRECTORY.md

* Add two more tests to is_ip_v4_address_valid.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-09-23 02:03:11 +08:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
Christian Clauss
78a5d3a558
boruvka.py: A few simplifications and f-strings (#4660)
* boruvka.py: A few simplifications and f-strings

Python f-strings simplify the code and [should speed up execution](https://www.scivision.dev/python-f-string-speed). 

@srkchowdary2000 Your review, please.

* updating DIRECTORY.md

* fixup! Streamline the test

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-08-24 15:27:31 +02:00
fpringle
8c13a7786f
feat: add solution for Project Euler problem 144 (#4280)
* Added solution for Project Euler problem 144

* updating DIRECTORY.md

* Better variable names

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-07-08 14:05:10 +05:30
Aniruddha Bhattacharjee
b743e44259
Wavelet tree (#4267)
* Added the matrix_exponentiation.py file in maths directory

* Implemented the requested changes

* Update matrix_exponentiation.py

* resolve merge conflict with upstream branch

* add new line at end of file

* add wavelet_tree

* fix isort issue

* updating DIRECTORY.md

* fix variable names in wavelet_tree and correct typo

* Add type hints and variable renaming

* Update data_structures/binary_tree/wavelet_tree.py

Add doctests to placate the algorithm-bot, thanks to @cclauss.

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

* Move doctest to individual functions and reformat code

* Move common test array to the global scope and reuse in tests

* MMove test array to global scope and minor linting changes

* Correct the failing pytest tests

* MUse built-in list for type annotation

* Update wavelet_tree.py

* types-requests

* updating DIRECTORY.md

* Update wavelet_tree.py

* # type: ignore

* # type: ignore

* Update decrypt_caesar_with_chi_squared.py

* ,

* Update decrypt_caesar_with_chi_squared.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Aniruddha Bhattacharjee <aniruddha@Aniruddhas-MacBook-Air.local>
2021-06-08 22:49:33 +02:00
Christian Clauss
71b458cefe
Rename harriscorner.py to harris_corner.py (#4470)
* Rename harriscorner.py to harris_corner.py

* updating DIRECTORY.md

* Rename meanthreshold.py to mean_threshold.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-05-31 21:19:09 +05:30
Dhruv Manilawala
ac29f70755
fix(action): correct indentation for types key (#4445)
* fix(action): correct indentation for types key

* updating DIRECTORY.md

* refactor: add quotes around name key

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-05-21 19:03:56 +05:30
algobytewise
1a39970538
Add rgb_hsv_conversion.py (#4334)
* Add rgb_hsv_conversion.py

* updating DIRECTORY.md

* snake-case

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-04-23 08:24:01 +02:00
algobytewise
536fb4bca4
Add algorithm for N-body simulation - retry (#4298)
* add n_body_simulation.py

* updating DIRECTORY.md

* Rename other/n_body_simulation.py to physics/n_body_simulation.py

* updating DIRECTORY.md

* Update build.yml

* refactor examples & add doctests

* removed type-hints from self-parameter

* Apply suggestions from code review

* Update physics/n_body_simulation.py

* Update physics/n_body_simulation.py

* Update physics/n_body_simulation.py

* Don't forget self

* Fix velocity

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-04-04 13:23:48 +02:00
algobytewise
35901eb6fe
Move: traversals/binary_tree_traversals.py --> searches/binary_tree_traversal.py (#4295)
* Rename traversals/binary_tree_traversals.py to searches/binary_tree_traversal.py

* updating DIRECTORY.md

* Delete traversals directory

* Update build.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-27 10:18:48 +01:00
algobytewise
a8db5d4b93
[mypy] fix compression folder (#4290)
* Update lempel_ziv.py

* Update build.yml

* updating DIRECTORY.md

* fix doctest in 2_hidden_layers_neural_network.py

* one more doctest

* simplified tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-22 19:24:05 +01:00
DevanshiPatel18
dd757dce38
feat: Add greedy_coin_change.py algorithm (#3805)
* Hacktoberfest: Add greedy_coin_change.py file 

added the file in greedy_methods folder to implement the same method

Altered the code according to the changes that were requested.

* Added doctests.

doctests added to the function find_minimum_change.

* Added Greedy change file in Maths folder.

* updating DIRECTORY.md

* Deleted Greedy Method Folder

* updating DIRECTORY.md

* Update greedy_coin_change.py

* fix: black formatting issues

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2021-03-20 11:48:38 +05:30
fpringle
89a43c81e5
feat: Add solution for Project Euler Problem 121 (#4261)
* Added solution for Project Euler problem 121

* Updated typing for 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-20 11:29:48 +05:30
Christian Clauss
b8a19ccfea
GitHub Actions: fast-fail on black formatting issues (#4268)
* GitHub Actions: fast-fail on black formatting issues

Give fast feedback to contributors https://github.com/psf/black#github-actions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-20 10:39:56 +05:30
fpringle
ecf9b8164f
Added solution for Project Euler problem 109 (#4080)
* Added solution for Project Euler problem 109

* New subscriptable builtin types

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-06 18:59:52 +05:30
ulwlu
a796ccf1ce
Add graham scan algorithm (#4205)
* Add graham scan algorithm

* Fix argument name p with point

* Add tests in inner function

* updating DIRECTORY.md

* Fix graham scan for isort --profile=black

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-02 13:24:41 +01:00
Tapajyoti Bose
7d26ba7075
Added diffie-hellman algorithm (#4128)
* updating DIRECTORY.md

* feat: added diffie-hellman key exchange algorithm

* fix: enforce maxline length = 88

* fix: fixed import order

* fix: used flake to correct styling

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-01-21 08:30:47 +05:30
fpringle
80f5213df5
Add solution for Project Euler problem 107 (#4066)
* Added solution for Project Euler problem 107

* Doctests and better variable names

* Type hints

* Small edits

* Forward reference for typing hint

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-28 13:21:02 +05:30
fpringle
0ccb213c11
Add solution for Project Euler problem 102 (#4051)
* Added solution for Project Euler problem 102

* Got rid of map functions

* Snake case variable names

* Type hints

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-23 23:18:19 +05:30
fpringle
2ff2ccbeec
Add solution for Project Euler problem 101 (#4033)
* Added solution for Project Euler problem 101

* Got rid of map functions

* updating DIRECTORY.md

* Better function/variable names

* Better variable names

* Type hints

* Doctest for nested function

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-22 17:32:31 +05:30
fpringle
ae8a5f8675
Add solution for Project Euler problem 59 (#4031)
* Added solution for Project Euler problem 59

* updating DIRECTORY.md

* Formatting, type hints, no more evil map functions

* Doctests

* Added doctests for Project Euler problem 59

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-13 16:39:52 +05:30
fpringle
a6f6eb2649
Add solution for Project Euler problem 86 (#4025)
* Added solution for Project Euler problem 86

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-12 10:49:35 +05:30
fpringle
75759fae22
Add solution for Project Euler problem 085 (#4024)
* Added solution for Project Euler problem 085.

* updating DIRECTORY.md

* Minor tweaks to Project Euler problem 85

* Variable comments for project euler problem 85

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-10 18:48:17 +05:30
fpringle
b1801398ec
Add Project Euler Problem 180 (#4017)
* Added solution for Project Euler problem 180

* Fixed minor details in Project Euler problem 180

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-12-09 16:44:51 +05:30
Maliha
860d4f547b
Create merge_two_lists.py that implements merging of two sorted linked lists (#3874)
* Create merge_two_lists.py that implements merging of two sorted linked lists

* Update merge_two_lists.py

Fixed formatting errors

* Fixed trailing whitespace

* Change name of function to def __str__()

* updating DIRECTORY.md

* Imported classes from singly_linked_list.py

* Update merge_two_lists.py

* Update merge_two_lists.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-12-03 16:02:48 +01:00
Dhruv Manilawala
f8b2c43fda
Fix pre-commit error on master (#3992)
* Update pigeon_sort.py

* updating DIRECTORY.md

* Add type hints and return annotation

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-30 21:03:29 +05:30
Jenia Dysin
e07766230d
Add static typing to backtracking algorithms (#2684)
* Added static typing to backtracking algorithms

* Ran psf/black to fix some minor issues.

* updating DIRECTORY.md

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-11-30 00:19:50 +08:00
Du Yuanchao
bfb0c3533d
Fixed LGTM and typehint (#3970)
* fixed LGTM
fixed typehint

* updating DIRECTORY.md

* Update lucas_series.py

* Update lucas_series.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-11-28 22:42:30 +08:00
fpringle
1e1708b8a1
Added solution for Project Euler problem 77 (#3132)
* Added solution for Project Euler problem 77.

* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256

* Implemented lru_cache, better type hints, more doctests for problem 77

* updating DIRECTORY.md

* updating DIRECTORY.md

* Added solution for Project Euler problem 77. Fixes: 2695

* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256

* Implemented lru_cache, better type hints, more doctests for problem 77

* better variable names

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-27 21:38:14 +05:30
Christian Clauss
3fdbf9741d
Python 3.9 (#3926)
* Upgrade to Python 3.9

* pip install wheel for faster builds

* updating DIRECTORY.md

* requirements.txt: tensorflow; python_version < '3.9'

* keras requires tensorflow

* Rename lstm_prediction.py to lstm_prediction.py_tf

* Update requirements.txt

* updating DIRECTORY.md

* Update requirements.txt

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-11-24 12:41:10 +01:00
Cory Metcalfe
b55e132b80
Add solution for Project Euler: Problem 89 (#2948)
* add solution for euler problem 89

* updates to accommodate euler solution guideline updates

* use more descriptive vars

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-21 10:59:29 +05:30
Peter Yao
28d33f4b2d
Project Euler 70 Solution (#3041)
* Add solution for Project Euler 70, Fixes: #2695

* Remove parameter from solution()

* Add tests for all functions, add fstring and positional arg for solution()

* Rename directory to 070

* Move up explanation to module code block

* Move solution() below helper functions, rename variables

* Remove whitespace from defining min_numerator

* Add whitespace

* Improve type hints with typing.List

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-11-21 08:12:07 +05:30
Christian Clauss
bb693aa681
Delete Travis_CI_tests_are_failing.md (#3902)
* Delete Travis_CI_tests_are_failing.md

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-19 22:18:47 +05:30
poloso
c6dd975389
Add type hints and tests. (#2461)
* Add type hints, documentation and tests.

* Update searches/ternary_search.py

Sort collection and remove the assertion logic.

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

* Remove assert sorted logic.

* Add assertion list is ordered.

* updating DIRECTORY.md

* updating DIRECTORY.md

* Format with black.

* Change names of variables to descriptive names

* Remove print in doctests

* Fix variables to snake_case notation.

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-14 22:34:29 +05:30
Prakhar Gurunani
a6ad25c351
Add molecular_chemistry.py (#2944)
* Create molecular_chemistry.py

* round up outputs

* Remove floating point

* Add Wikipedia references

* fixup! Format Python code with psf/black push

* Add Conversions/Molecular Chemistry

* updating DIRECTORY.md

* Update molecular_chemistry.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-11-10 08:20:27 +01:00
Peter Yao
61cb921d87
Project Euler 206 Solution (#3829)
* Readd Project Euler 206 solution for issue #2695, dupe of pull request #3042

* Add PE 206 to directory

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-02 23:24:20 +05:30
Du Yuanchao
786b32431c
Update infix to postfix (#3817)
* add test to infix_to_postfix_conversion

* fixed pre-commit error

* fixed build error

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-11-02 00:35:31 +08:00
Du Yuanchao
a03b3f763f
Balanced parentheses (#3768)
* Fixed balanced_parentheses.py

* fixed pre-commit

* eliminate is_paired

* remove unused line

* updating DIRECTORY.md

* Update data_structures/stacks/balanced_parentheses.py

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

* Add more test cases

* Update data_structures/stacks/balanced_parentheses.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-10-29 10:39:19 +01:00
PetitNigaud
99adac0eb1
Add first solution for Project Euler Problem 207 (#3522)
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36cab.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf4ef.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: #2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-29 12:34:42 +05:30
John Law
a5aef147e9
Fix Project Euler Readme (#3754)
* Fix Project Euler Readme

* updating DIRECTORY.md

* Update CONTRIBUTING.md

* spacing

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-26 21:18:57 +05:30
Du Yuanchao
81b82bea47
Update ceil and floor function (#3710)
* Update ceil and floor function

* add end line

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-26 00:02:24 +08:00
Peter Yao
20260d2b9c
Add Project Euler 65 Solution (#3035)
* Add solution for Project Euler 65,

* Add URL to problem 65 and don't pass in parameter to solution()

* Remove solution() tests

* Add tests for solution(), add fstring and positional arg for solution

* Rename directory and problem number to 065

* Remove directory

* Move up explanation to module code block

* Move solution() below helper function, rename variables
2020-10-24 07:55:15 +05:30
Christian Clauss
9b95e4f662
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 12:46:14 +02:00
JoaoVictorNascimento
79d57552aa
Add Patience Sort (#3469)
* Add Patience Sort

* fix code for pre-commit

* Fix params def

* Adding new line at end of file

* Remove Trailing Whitespace

* Adding space between the methods of the Stack class

* Removing Trailing Whitespace

* Ordering Imports

* Adding url patience sort

Co-authored-by: jvnascimento <nascimento783@gmail.com>
2020-10-18 23:44:19 +02:00
Christian Clauss
a481bfa231
Fix broken build: Remove trailing spaces (#3501)
* Fix broken build: Remove trailing spaces

* updating DIRECTORY.md

* One more trailing space

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-18 18:07:27 +02:00
Christian Clauss
f34434a214
Fix the build -- 88 chars per line max. (#3437)
* Fix the build -- 88 chars per line max.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-17 13:42:29 +02:00
Christian Clauss
5b024f4dd5
BROKEN BUILD: Fix a failing precommit test (#3344)
* Fix a failing precommit test

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-16 00:33:25 +02:00
Christian Clauss
2e90debab3
Tighten up quicksort() (#3319)
* Tighten up quicksort()

* updating DIRECTORY.md

* str does not support .pop()

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 15:07:34 +02:00
Christian Clauss
7c5cc28ba2
Revert recent changes to .pre-commit-config.yaml (#3318)
* Revert recent changes to .pre-commit-config.yaml

We must continue to insist that algorithmic functions can not print() as discussed in CONTRIBUTING.md.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 16:50:43 +05:30
Christian Clauss
aeb6edc792
.pre-commit-config.yaml: Disable trailing-whitespace fixer (#3306)
* .pre-commit-config.yaml: Disable trailing-whitespace fixer

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-15 11:11:22 +02:00
Peter Yao
671ab1d863
Project Euler 62 Solution (#3029)
* Add solution for Project Euler 62

* Add doctests and annotate function params and return values for get_digits()

* Add extra newline between functions to fix flake8 errors

* Add extra newlines between function names

* Add missing return type for solution()

* Remove parenthesis from if statement

* Remove parentheses from while loop

* Add to explanation and fix second Travis build

* Compress get_digits(), add tests for solution(), add fstring and positional arg for solution()

* Remove input param when calling solution()

* Remove test case for the answer
2020-10-15 09:13:39 +05:30
Christian Clauss
fda57d6924
codespell.yml: Remove unused install of flake8 (#3283)
* codespell.yml: Remove unused install of flake8

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 17:02:47 +05:30
Susmith98
dc069580b9
Added binary tree mirror algorithm (#3159)
* Added binary tree mirror algorithm

* Minor changes

* Resolved comments

* Minor Changes

* resolved comments and updated doctests

* updated doctests

* updating DIRECTORY.md

Co-authored-by: svedire <VedireSusmith_Reddy@intuit.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 12:21:15 +02:00
Dhruv
23ab159f30
Fix errors in Quantum algorithm (#3273)
* Fix pre-commit errors in Quantum algorithm

* updating DIRECTORY.md

* Fix doctest

* Update not_gate.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-14 07:58:52 +02:00
Dhruv
34d63d5155
Fix Travis CI slow build on Project Euler Solution job (#3262)
* Fix Travis CI long run for validate_solutions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-13 22:43:40 +05:30
Abhishek Jaisingh
6e01004535
Add First Quantum Qiskit Code Tutorial (#3173)
* Add First Quantum Qiskit Code Tutorial

* Add Qiskit Requirement

* Address Review Comments

* fixup! Format Python code with psf/black push

* Update q1.py

* updating DIRECTORY.md

* Update and rename q1.py to single_qubit_measure.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-12 21:41:05 +02:00
Kushagra Bansal
08c26e667b
Update CODEOWNERS to add my preferences (#3233)
* Update CODEOWNERS

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-12 16:23:21 +02:00
Christian Clauss
f7e7ad2ef6
CONTRIBUTING.md Jupyter files belong in the Jupyter repo. (#3211)
* CONTRIBUTING.md Jupyter files belong in the Jupyter repo.

* updating DIRECTORY.md

* Update CONTRIBUTING.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-12 08:17:26 +08:00
Christian Clauss
731190842a
CODEOWNERS: Proper spelling of my userid (#3185)
* CODEOWNERS: Proper spelling of my userid

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-11 15:23:30 +05:30
Sandeep Gupta
c07b82fa63
Add Project Euler Problem 80 (#2885)
* adding solution to problem 80

* updating DIRECTORY.md

* fixing spell check

* updating sol as per comments

* Add reference link to the problem

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-10 17:06:25 +05:30
Tapajyoti Bose
02d3ab81bd
feat: added prim's algorithm v2 (#2742)
* feat: added prim's algorithm v2

* updating DIRECTORY.md

* chore: small tweaks

* fixup! Format Python code with psf/black push

* chore: added algorithm descriptor

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 12:18:52 +05:30
Tapajyoti Bose
8bd4ca67be
Added all sub sequence type hints [Hacktober Fest] (#3123)
* updating DIRECTORY.md

* chore(all-subsequence): added type hints [HACKTOBER-FEST]

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 11:49:36 +05:30
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