Commit Graph

315 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
6cd7c49525
[pre-commit.ci] pre-commit autoupdate (#7920)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v3.1.0 → v3.2.0](https://github.com/asottile/pyupgrade/compare/v3.1.0...v3.2.0)

* updating DIRECTORY.md

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-31 21:33:08 +01:00
Christian Clauss
a31edd4477
Test on Python 3.11 (#6591)
* Test on Python 3.11 release candidate 2

* tensorflow; python<3.11

* tensorflow; python_version < 3.11

* tensorflow; python_version < "3.11"

* sympy, tensorflow; python_version < "3.11"

* sklearn; python_version < "3.11"

* matplotlib, pandas, qiskit

* statsmodels; python_version < "3.11"

* Bring back Pandas

* Problem deps are qiskit, statsmodels, and tensorflow

* updating DIRECTORY.md

* python-version: 3.11-dev --> 3.11

* updating DIRECTORY.md

* Add pytest --ignore to pyproject.toml

* Update build.yml

* Update pyproject.toml

* Update pyproject.toml

* Python 3.11

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-31 14:50:03 +01:00
Tianyi Zheng
39e5bc5980
Refactor bottom-up edit distance function to be class method (#7347)
* Refactor bottom-up function to be class method

* Add type hints

* Update convolve function namespace

* Remove depreciated np.float

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* updating DIRECTORY.md

* Renamed function for consistency

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Chris O <46587501+ChrisO345@users.noreply.github.com>
2022-10-31 18:13:21 +13:00
happiestbee
00fc53de97
added sumset.py Fixes: #{6563} (#6742)
* Create sumset.py

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add descriptive var names

* Update maths/sumset.py

Co-authored-by: Caeden <caedenperelliharris@gmail.com>

* Update sumset.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-30 11:49:05 +01:00
Andrey
57ccabbaeb
Update docs (#7867)
* Update docs, remove unused excludes from pre-commit

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-30 10:01:58 +01:00
Andrey
1550731cb7
Remove file-level flake8 suppression (#7844)
* Remove file-level flake8 suppression

* updating DIRECTORY.md

* Fix tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-29 22:45:21 +02:00
Andrey
584e743422
Fix yesqa hook (#7843)
* fix yesqa hook

* Remove redundant noqa

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-29 15:07:02 +02:00
Andrey
a9bd68d96e
Add running doctest to pytest default (#7840)
* Add default options for pytest

* updating DIRECTORY.md

* Move pytest settings to pyproject.toml

* Move coverage settings to the pyproject.toml

* Return --doctest-continue-on-failure to pytest

* Convert pytest args to list

* Update pyproject.toml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-29 14:27:47 +02:00
Christian Clauss
19bff003aa
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
* Adopt Python >= 3.8 assignment expressions using auto-walrus

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-28 15:54:54 +02:00
Christian Clauss
74325d079c
Rename quantum_random.py to quantum_random.py.DISABLED.txt (#7683)
* Rename quantum_random.py to quantum_random.py.DISABLED.txt

#7682

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-26 22:08:53 +02:00
Maxim Smolskiy
d407476531
fix: increase str conversion limit where required (#7604)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-25 06:27:03 +05:30
Maxim Smolskiy
a041b64f7a
feat: add Project Euler problem 073 solution 1 (#6273)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-24 18:59:49 +05:30
Laukik Chahande
39a99b46f5
check whether integer is even or odd using bit manupulation (#7099)
* even_or_not file added

* Updated DIRECTORY.md

* modified DIRECTORY.md

* Update bit_manipulation/even_or_not.py

* updating DIRECTORY.md

* Rename even_or_not.py to is_even.py

* updating DIRECTORY.md

Co-authored-by: luciferx48 <laukik.22010776@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-23 19:26:22 +02:00
Christian Clauss
81ccf54c75
Rename xgboostclassifier.py to xgboost_classifier.py (#7550)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-23 18:39:25 +05:30
Tianyi Zheng
cc10b20beb
Remove some print statements within algorithmic functions (#7499)
* Remove commented-out print statements in algorithmic functions

* Encapsulate non-algorithmic code in __main__

* Remove unused print_matrix function

* Remove print statement in __init__

* Remove print statement from doctest

* Encapsulate non-algorithmic code in __main__

* Modify algorithm to return instead of print

* Encapsulate non-algorithmic code in __main__

* Refactor data_safety_checker to return instead of print

* updating DIRECTORY.md

* updating DIRECTORY.md

* Apply suggestions from code review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-22 13:33:51 +02:00
Tianyi Zheng
2859d4bf3a
Remove references to depreciated QasmSimulator (#7417)
* Fix typos

* Replace depreciated QasmSimulator in Deutsch-Jozsa algorithm

* Replace depreciated QasmSimulator in half adder algorithm

* Replace depreciated QasmSimulator in not gate algorithm

* Replace depreciated QasmSimulator in full adder algorithm

* Simplify qiskit import

* Make formatting more consistent

* Replace depreciated QasmSimulator in quantum entanglement algorithm

* Replace depreciated QasmSimulator in ripple adder algorithm

* Replace depreciated QasmSimulator in qubit measure algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* updating DIRECTORY.md

* Remove qiskit import alias for clarity

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-19 22:12:44 +02:00
Nadirhan Şahin
b90ec30398
Create combination_sum.py (#7403)
* Create combination_sum.py

* Update DIRECTORY.md

* Adds doctests

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

* Update combination_sum.py

* Update combination_sum.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-18 21:55:43 +02:00
pre-commit-ci[bot]
0c7c5fa7b0
[pre-commit.ci] pre-commit autoupdate (#7387)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v3.0.0 → v3.1.0](https://github.com/asottile/pyupgrade/compare/v3.0.0...v3.1.0)
- [github.com/codespell-project/codespell: v2.2.1 → v2.2.2](https://github.com/codespell-project/codespell/compare/v2.2.1...v2.2.2)

* updating DIRECTORY.md

* Fix typo discovered by codespell

* Fix typo discovered by codespell

* Update .pre-commit-config.yaml

* Update .pre-commit-config.yaml

* Update .pre-commit-config.yaml

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-17 21:59:25 +02:00
SudhanshuSuman
7f6e0b656f
Corrected the directory of Fractional Knapsack algorithm (#7086)
* Moved fractional knapsack from 'dynamic_programming' to 'greedy_methods'

* Updated DIRECTORY.md
2022-10-16 22:41:28 +02:00
Caeden
98a4c24878
feat: Binary tree node sum (#7020) (#7162)
* feat: Binary tree node sum (#7020)

* feat: Sum of all nodes in binary tree explanation (#7020)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update data_structures/binary_tree/binary_tree_node_sum.py

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

* refactor: Change replace method with `__iter__` overriding (#7020)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-15 14:58:09 +02:00
Dhruv Manilawala
70b60dc323
chore: remove inactive user from CODEOWNERS (#7205)
* chore: remove inactive user from CODEOWNERS

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-15 08:37:59 +02:00
GURNEET SINGH
e661b98829
Binary Search Tree Inorder Traversal Algorithm (#6840)
* Binary Search Tree Inorder Traversal

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Binary Search Tree Inorder Traversal v2

* Binary Search Tree Inorder Traversal

* Binary Search Tree Inorder Traversal

* Update inorder_tree_traversal_2022.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update inorder_tree_traversal_2022.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update inorder_tree_traversal_2022.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update data_structures/binary_tree/inorder_tree_traversal_2022.py

* Update data_structures/binary_tree/inorder_tree_traversal_2022.py

* Updated

* Updated

* Update inorder_tree_traversal_2022.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update inorder_tree_traversal_2022.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update data_structures/binary_tree/inorder_tree_traversal_2022.py

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

* Updated and removed print statement

removed the print from inorder function

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-13 14:09:01 +02:00
Christian Clauss
bae08adc86
README.md: Lose LGTM badge because we don't use it (#7063)
* README.md: Lose LGTM badge because we don't use it

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-12 20:56:07 +01:00
pre-commit-ci[bot]
0a3433eaed
[pre-commit.ci] pre-commit autoupdate (#6940)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.8.0 → 22.10.0](https://github.com/psf/black/compare/22.8.0...22.10.0)
- [github.com/asottile/pyupgrade: v2.38.2 → v3.0.0](https://github.com/asottile/pyupgrade/compare/v2.38.2...v3.0.0)
- [github.com/pre-commit/mirrors-mypy: v0.981 → v0.982](https://github.com/pre-commit/mirrors-mypy/compare/v0.981...v0.982)

* updating DIRECTORY.md

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-10 22:04:33 +02:00
Jordan Rinder
5894554d41
Add Catalan number to maths (#6845)
* Add Catalan number to maths

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-08 23:28:17 +01:00
Christian Clauss
3d33b36e92
Fix pre-commit.ci: additional_dependencies: [types-requests] (#6559)
* Fix pre-commit.ci: additional_dependencies: [types-requests==2.28.11]

* updating DIRECTORY.md

* Update .pre-commit-config.yaml

* additional_dependencies: [types-requests]

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-10-02 21:59:17 +02:00
Maxim Smolskiy
a0b0f414ae
Add Project Euler problem 116 solution 1 (#6305)
* Add solution

* updating DIRECTORY.md

* Fix pre-commit

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-09-24 18:04:00 +01:00
Satish Mishra
45d3eabeb5
Add Optimized Shell Sort (#6225)
* Add Optimized Shell Sort

* Added return type

* reformatted

* added shrink_shell.py

* ran directory generator

* Rename shrink_shell.py to shrink_shell_sort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-09-14 09:43:08 +01:00
zhexuanl
b1818af517
Add Digital Image Processing Algorithm: Local Binary Pattern (#6294)
* add algorithm local binary pattern

* fix failed test for local binary pattern

* updating DIRECTORY.md

* fix detected precommit-error

* fix precommit error

* final check

* Add descriptive name for parameters  x and y

* Update digital_image_processing/filters/local_binary_pattern.py

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

* Update digital_image_processing/filters/local_binary_pattern.py

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

* Update digital_image_processing/filters/local_binary_pattern.py

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

* Update local_binary_pattern.py

* undo changes made on get_neighbors_pixel()

* files formatted by black

* Update digital_image_processing/filters/local_binary_pattern.py

ok thanks

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

* add test for get_neighbors_pixel() function

* reviewed

* fix  get_neighbors_pixel

* Update test_digital_image_processing.py

* updating DIRECTORY.md

* Create code_quality.yml

* Create code_quality.yml

* Delete code_quality.yml

* Update code_quality.yml

* Delete code_quality.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-08-24 06:48:54 +02:00
Maxim Smolskiy
063a0eced9
feat: add Project Euler problem 115 solution 1 (#6303)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-08-07 16:50:45 +05:30
Maxim Smolskiy
a69d880bb5
feat: add Project Euler problem 114 solution 1 (#6300)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-08-07 07:37:35 +05:30
Maxim Smolskiy
97f25d4b43
feat: add Project Euler problem 587 solution 1 (#6269)
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-26 21:45:14 +05:30
Maxim Smolskiy
c45fb3c294
perf: Project Euler problem 145 solution 1 (#6259)
Improve solution (~30 times - from 900+ seconds to ~30 seconds)

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-23 07:23:46 +05:30
Nikos Giachoudis
f7c58e4c4b
Unify primality checking (#6228)
* renames prime functions and occurances in comments

* changes implementation of primality testing to be uniform

* adds static typing as per conventions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-11 22:36:57 +08:00
Christian Clauss
dad789d903
Get rid of the Union (#6246)
* Get rid of the Union

* updating DIRECTORY.md

* Get rid of the Union

* Remove the redundant pre-commit runs.

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-11 13:11:17 +02:00
Christian Clauss
0a0f4986e4
Upgrade GitHub Actions (#6236)
* Upgrade GitHub Actions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-07 05:25:25 +02:00
Vcrostin
69cde43ca1
make DIRECTORY.md paths relative Fixes (#6179) (#6190) 2022-06-22 12:01:05 +08:00
kugiyasan
8004671b98
Add Project Euler 68 Solution (#5552)
* updating DIRECTORY.md

* Project Euler 68 Solution

* updating DIRECTORY.md

* Project Euler 68 Fixed doctests, now at 93% coverage

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: kugiyasan <kugiyasan@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-05-27 03:24:23 +08:00
Maxim Smolskiy
de4d98081b
Improve Project Euler problem 145 solution 1 (#6141)
* updating DIRECTORY.md

* Improve solution

* updating DIRECTORY.md

* Fix

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-05-24 09:20:47 +08:00
Lukas
7a9b3c7292
Added average absolute deviation (#5951)
* Added average absolute deviation

* Formats program with black

* reruns updated pre commit

* Update average_absolute_deviation.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-02-13 18:20:19 +01:00
Christian Clauss
f707f6d689
Upgrade to Python 3.10 (#5992)
* Upgrade to Python 3.10

* Upgrade to Python 3.10

* mypy || true

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-02-13 06:57:44 +01:00
Christian Clauss
24d3cf8244
The black formatter is no longer beta (#5960)
* The black formatter is no longer beta

* pre-commit autoupdate

* pre-commit autoupdate

* Remove project_euler/problem_145 which is killing our CI tests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-01-30 20:29:54 +01:00
Michael Currin
7423875cef
ci: add mkdir step for mypy (#5927)
* ci: add mkdir step for mypy

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-01-26 23:35:51 +08:00
Christian Clauss
1ae5abfc3c
Replace typing.optional with new annotations syntax (#5829)
* Replace typing.optional with new annotations syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-17 04:43:02 +01:00
Rohan R Bharadwaj
e9882e41ba
[mypy] Fix matrix_operation.py (#5808)
* Update matrix_operation.py

* Update mypy.ini

* Update DIRECTORY.md

* formatting

* Update matrix_operation.py

* doctest for exception

* A bit more...
2021-11-10 16:22:52 +01:00
Nivas Manduva
c3d1ff0ebd
Add Jacobi Iteration Method (#5113)
* Added Jacobi Iteration Method

Added this method in arithmetic_analysis folder. This method is used to solve system of linear equations.

* Added comments

* Added reference link

* Update jacobi_iteration_method.py

* Changes for codespell test

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* updating DIRECTORY.md

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* fix styles

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-09 22:40:57 +08:00
Maxim Smolskiy
0b8d6d70ce
Add Project Euler problem 205 solution 1 (#5781)
* updating DIRECTORY.md

* Add solution

* updating DIRECTORY.md

* Fix

* Fix

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-09 22:25:29 +08:00
Dylan Buchi
ac4bdfd66d
[mypy] Fix type annotations in graphs/boruvka.py (#5794)
* Fix type annotations in boruvka.py

* Remove graphs/boruvka.py|

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-08 21:47:09 +08:00
Rohan R Bharadwaj
db5aa1d188
Add equated_monthly_installments.py in Financials (#5775)
* Add equated_monthly_installments.py in Financials

* Formatting

* More formatting, Descriptive names

* Errors with name change

* Formatting

* Formatting, Naming Error

* dedent

* Update DIRECTORY.md
2021-11-07 15:40:23 +01:00
Maxim Smolskiy
1a43c92c77
Improve Project Euler problem 043 solution 1 (#5772)
* updating DIRECTORY.md

* Fix typo

* Improve solution

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-05 20:44:24 +01:00
Souvik Ghosh
0ea5c734e1
sock_merchant.py: Matching socks by color (#5761)
* Python file for finding number of pairs

* updating DIRECTORY.md

* fixed iterative_pair.py

* further fixed with type casting

* fixed naming conventions

* further fixed with naming convention

* documented done

* build issue fixed

* updating DIRECTORY.md

* Revert "documented done"

This reverts commit 3be15ca374.

* Update canny.py

* Update test_digital_image_processing.py

* Update sobel_filter.py

* requirements.txt fixed

* keras<2.7.0

* Update sock_merchant.py

* doctest with black fixed

* Update sock_merchant.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-11-03 21:24:50 +01:00
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