Commit Graph

82 Commits

Author SHA1 Message Date
Caeden Perelli-Harris
9bba42eca8
refactor: Indent ... for visual purposes (#7744) 2022-10-27 19:42:30 +02:00
Caeden
6e69181d1f
refactor: Replace list() and dict() calls with literals (#7198) 2022-10-15 06:37:03 +05:30
Caeden
07e991d553
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038)

* refactor: Fix naming conventions (#7038)

* Update arithmetic_analysis/lu_decomposition.py

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

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

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

* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038)

* chore: Fix naming conventions in doctests (#7038)

* fix: Temporarily disable project euler problem 104 (#7069)

* chore: Fix naming conventions in doctests (#7038)

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-13 00:54:20 +02:00
Vardhaman
2d5dd6f132
MAINT: Updated f-string method (#6230)
* MAINT: Used f-string method

Updated the code with f-string methods wherever required for a better and cleaner understanding of the code.

* Updated files with f-string method

* Update rsa_key_generator.py

* Update rsa_key_generator.py

* Update elgamal_key_generator.py

* Update lru_cache.py

I don't think this change is efficient but it might tackle the error as the error was due to using long character lines.

* Update lru_cache.py

* Update lru_cache.py

Co-authored-by: cyai <seriesscar@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-07-07 16:34:07 +02: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
Rohan R Bharadwaj
745f9e2bc3
[mypy] Type annotations for searches directory (#5799)
* Update ternary_search.py

* Update mypy.ini

* Update simulated_annealing.py

* Update ternary_search.py

* formatting

* formatting

* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py
2021-11-09 16:48:30 +01:00
harshitkap00r
ce9a139b56
Update binary_search.py (#4856)
Take less time to calculate
2021-10-27 12:25:48 +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
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
Christian Clauss
987567360e
Update our pre-commit dependencies (#4273)
* .pre-commit-config.yaml: mypy directories that pass

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-20 10:42:17 +05:30
Umair Kamran
bd4b83fcc7
Chore: Added type hints to searches/binary_search.py (#2682)
* Chore: Added type hints to searches/binary_search.py

* Use -1 as the sentinal value

* Wrap long lines

* Update binary_search.py

* Update binary_search.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-12-09 15:01:58 +01:00
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
jbaenaxd
1f65007456
Shortened code (#3855) 2020-11-01 15:38:11 +08:00
poloso
21581eae3b
Fix: Multiple errors in fibonacci search. (#2659)
* Fix: Multiple errors in fibonacci search.

- Test lists were not ordered, this is required for Fibonacci search
- Place documentation of function inside function
- Create multiple different tests including, float, char and negatives
- Add type hints in line with #2128

* Fix: sort of modules and delete typehint.

* Apply suggestions from code review

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Correct invocation of lru_cache.

* Add check for input in fibonacci and doctest.

* Correct typehints to comply to numpy style.

* Correct ValueError to TypeError.

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Correct doctest for TypeError.

* Rename  single letter names as mentioned in CONTRIBUTING.md.

* Fix: Bug in big lists.

* Remove print(.) in doctests.

* Refactor iterator to while loop.

* Update searches/fibonacci_search.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 09:06:19 +05:30
poloso
40db8c205f
Fix: Corrected test. List in test must be ordered. (#2632)
* Fix: Corrected test. List in test must be ordered.

* Add tests with big lists.
2020-10-07 19:57:19 +05:30
Dmytro Litvinov
7df91e681a
Add type hints for searches/ternary_search.py (#2874) 2020-10-05 23:14:35 +05:30
Dhruv
9016fe192f
Fix imports for all namespace packages (#2506)
* Fix imports as they're namespace packages

* Fix import for scripts/validate_filenames.py

* Fix path in doctest
2020-09-28 23:41:04 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
dc415ec14a
Added double linear search recursion (#2445)
* double linear search recursion

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-18 09:55:02 +02:00
poloso
86fb2991d5
Corrected filename and include static types (#2440)
* Corrected name and include static types

- The name of the file is now compliant with python naming conventions
- Add static type as stated in contributing guidelines

* Apply suggestions from code review

- Delete documentation line to run doctests
- Delete type hints for variables that comes from functions

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

* Add edge cases tests.

* print(f"{target} was {not_str}found in {sequence}")

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-17 09:41:10 +02:00
Ashley Jeji George
799fde4c07
Update linear_search.py (#2422)
* Update linear_search.py

Python implementation of recursive linear search algorithm

* Update linear_search.py

Added different doctests
Added the parameter hints
Handled the exception

* Update linear_search.py

added parameter hints to linear_search

* Update linear_search.py

Both the functions return the index if the target is found and -1 if it is not found
The rec_linear_search raises an exception if there is an indexing problem
Made changes in the doc comments

* Update linear_search.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-14 12:44:46 +02:00
Guillaume Rochedix
f754c0d31f
Jump search (#2415)
* jump_search: doctest, docstring, type hint, inputs

* jumpsearch.py: case number not found

* trailing whitespace jump search
2020-09-12 07:50:12 +02:00
Prashant Anand
b57b6abb48
fix doctests for recursive binary search (#2229) 2020-08-01 07:26:04 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Reinhold
64bef606b6
double_linear_search algorithm (#2161)
* linear search iterating from both array sides

* Update double_linear_search.py

* Update double_linear_search.py

* added doctests

* updated doctests

* Update double_linear_search.py

* Update double_linear_search.py

* added blank after >>>

* made all the requested changes

* Update double_linear_search.py

* Update double_linear_search.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-04 11:23:23 +02:00
Christian Clauss
b9e5259aeb
Fix long line, tests (#2123)
* Fix long line

* updating DIRECTORY.md

* Add doctest

* ...

* ...

* Update tabu_search.py

* space

* Fix doctest

    >>> find_neighborhood(['a','c','b','d','e','a'])  # doctest: +NORMALIZE_WHITESPACE
    [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90],
     ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102],
     ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]]

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-06-16 14:29:13 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Himanshu Airan
48bb14d4b2
Update linear_search.py (#1974)
* Update linear_search.py

Comment modified in line 17 as Sorting not required in Linear Search

* Update linear_search.py

Comment modified in line 17
2020-05-14 16:52:43 +02:00
Christian Clauss
6acd7fb5ce
Wrap lines that go beyond GitHub Editor (#1925)
* Wrap lines that go beyond GiHub Editor

* flake8 --count --select=E501 --max-line-length=127

* updating DIRECTORY.md

* Update strassen_matrix_multiplication.py

* fixup! Format Python code with psf/black push

* Update decision_tree.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 23:36:35 +02:00
Prince Gangurde
58271c5851
Update linear_search.py (#1906) 2020-04-24 12:34:18 +02:00
matkosoric
7f04e5cd34
contribution guidelines checks (#1787)
* spelling corrections

* review

* improved documentation, removed redundant variables, added testing

* added type hint

* camel case to snake case

* spelling fix

* review

* python --> Python # it is a brand name, not a snake

* explicit cast to int

* spaces in int list

* "!= None" to "is not None"

* Update comb_sort.py

* various spelling corrections in documentation & several variables naming conventions fix

* + char in file name

* import dependency - bug fix

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
onlinejudge95
4866b1330b
Fixes black failures from Previous PR (#1751)
* Fixes black failures from Previous PR

* Fixes equality testing alert

* Fixes call to main() alert

* Fixes unused import
2020-02-13 02:19:41 +05:30
onlinejudge95
6fdd53c676
Fixes LGTM issues (#1745)
* Fixes redefinition of a variable

* Fixes implementing __eq__

* Updates docstring
2020-02-10 22:23:19 +01:00
cschuerc
81f077adfc Augment binary search algorithms (#1719) 2020-01-28 22:33:59 +05:30
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Faraz Ahmed Khan
c01d178798 Added implementation for simulated annealing (#1679)
* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Update and rename optimization/hill_climbing.py to searches/hill_climbing.py

* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Rebased

* added simulated annealing.py

* added final comments and test

* black formatted

* restricted search domain

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-17 23:32:06 +01:00
Christian Clauss
1f2b1a88ab Typos in comments in hill_climbing.py (#1667)
* Typos in comments in hill_climbing.py

* fixup! Format Python code with psf/black push
2020-01-08 21:06:53 +08:00
Faraz Ahmed Khan
cbab5f18f1 added hill climbing algorithm (#1666)
* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Update and rename optimization/hill_climbing.py to searches/hill_climbing.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-08 06:00:55 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08:00
percy07
df95f43907 Update quick_select.py (#1523)
* Update quick_select.py

Add Doctests.

* Add typehints

* Don't pre-allocate "smaller" and "larger"
2019-10-30 16:10:30 +01:00
praisearts
7b3d385ad6 create simple binary search (#1430)
* create simnple binary search

#A binary search implementation to test if a number is in a list of elements

* Add .py, format with psf/black, and add doctests
2019-10-24 10:31:58 +02:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Laisha Wadhwa
9c634735d3 added fibonacci_search.py (#1341)
* added fibonacci_search.py

* added Fibonacci_search.py after error handling

* added doctests
2019-10-18 08:10:08 +02:00
Du YuanChao
0da4d0a7f3 make code more readable (#1304) 2019-10-08 13:22:40 +05:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02:00
cclauss
b7f13d991c Travis CI: Run black, doctest, flake8, mypy, and pytest (#964)
* Travis CI: Add type checking with mypy

* Create requirements.txt

* script: mypy --ignore-missing-stubs=cv2,numpy .

* Delete requirements.txt

* script: mypy --ignore-missing-imports .

* Run doctests

* Disable doctest -v other/detecting_english_programmatically.py

* Pytest

* No |

* pytest || true

* Run black doctest flake8 mypy pytest

* after_success: Build Directory.md

* Typo in filename: Dictionary.txt --> dictionary.txt'

Discovered via doctest run in #964

* python -m doctest -v

* pip install black flake8 mypy pytest

* pytest --doctest-glob='*.py'

* pytest --doctest-modules

* pytest --doctest-modules ./sorts

* pytest --doctest-modules ./ciphers ./other ./searches ./sorts ./strings || true

* if __name__ == "__main__":

* if __name__ == "__main__":

* if __name__ == '__main__':

* if __name__ == '__main__':

* if __name__ == '__main__':

* Create requirements.txt

* Update requirements.txt

* if __name__ == "__main__":

* Lose the doctests

* if __name__ == '__main__':

* Remove print-a-tuple

* doctest: Added missing spaces

* Update tabu_search.py

* The >>> are not doctests so change to >>)

* Travis CI: Run black, doctest, flake8, mypy, and pytest

* Link to the separate DIRECTORY.md file

* Update README.md
2019-07-08 23:27:51 +08:00