Commit Graph

51 Commits

Author SHA1 Message Date
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit (#7132)
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104)

* refactor: Fix ``flake8-builtins`` (#7104)

* fix(lru_cache): Fix naming conventions in docstrings (#7104)

* ci(pre-commit): Order additional dependencies alphabetically (#7104)

* fix(lfu_cache): Correct function name in docstring (#7104)

* Update strings/snake_case_to_camel_pascal_case.py

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

* Update data_structures/stacks/next_greater_element.py

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

* Update digital_image_processing/index_calculation.py

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

* Update graphs/prim.py

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

* Update hashes/djb2.py

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

* refactor: Rename `_builtin` to `builtin_` ( #7104)

* fix: Rename all instances (#7104)

* refactor: Update variable names (#7104)

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

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

* ci: Create ``tox.ini`` and ignore ``A003`` (#7123)

* revert: Remove function name changes (#7104)

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

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

* Rename tox.ini to .flake8

* Update data_structures/heap/heap.py

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

* refactor: Rename `next_` to `next_item` (#7104)

* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127)

* refactor: Follow `flake8-bugbear` plugin (#7127)

* fix: Correct `knapsack` code (#7127)

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

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

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
d5a9f649b8
Add flake8-builtins to pre-commit and fix errors (#7105)
Ignore `A003`

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 19:53:59 +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
Omkaar
dbee5f072f
Improve code on f-strings and brevity (#6126)
* Update strassen_matrix_multiplication.py

* Update matrix_operation.py

* Update enigma_machine2.py

* Update enigma_machine.py

* Update enigma_machine2.py

* Update rod_cutting.py

* Update external_sort.py

* Update sol1.py

* Update hill_cipher.py

* Update prime_numbers.py

* Update integration_by_simpson_approx.py
2022-05-13 20:51:44 +08: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
Studiex
218d8921db
Implementation of SHA-256 using Python (#5532)
* Add files via upload

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* Update sha256.py

* @staticmethod def preprocessing(data: bytes) -> bytes:

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-23 15:20:52 +02: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
46e56fa6f2
luhn.py: Favor list comprehensions over maps (#4663)
* luhn.py: Favor list comprehensions over maps

As discussed in CONTRIBUTING.md.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-08-27 11:45:14 +02:00
bum_fuzzle
7046fdcdc8
fixed #4529 (#4547)
fixed an indentation mistake
2021-07-19 16:06:43 +02:00
QuantumNovice
95a4957d9e
Luhn algorithm (#4487)
* Luhn algorithm

Perform Luhn validation on input string
    Algorithm:
    * Double every other digit starting from 2nd last digit.
    * Subtract 9 if number is greater than 9.
    * Sum the numbers
https://en.wikipedia.org/wiki/Luhn_algorithm

* Update DIRECTORY.md

* Update luhn.py

* Update luhn.py

* Update luhn.py

* Update luhn.py

* Update DIRECTORY.md
2021-06-13 23:49:44 +05:30
Dhruv Manilawala
6f21f76696
fix(ci): Update pre-commit hooks and apply new black (#4359)
* fix(ci): Update pre-commit hooks and apply new black

* remove empty docstring
2021-04-26 07:46:50 +02:00
algobytewise
a53fcf221b
[mypy] fix hashes folder (#4305)
* fix hashes-folder

* Update build.yml

* fix doctests

* return-values to int

* Update hashes/adler32.py

* type hints for elements

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-04-03 13:31:46 +05:30
CapofWeird
05f4089bf0
Fixed typo in caesar_cipher.py (#2979)
* Fixed typo in caesar_cipher.py

* Typo fixes
2020-10-17 13:26:11 +05:30
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
cbbaa98684
hamming_code.py: Reduce McCabe code complexity (#2140)
* hamming_code.py: Reduce McCabe code complexity

As discussed in #2128

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-22 14:18:57 +02:00
bnMikheili
62f7561428
Hash djb2 (#2098)
* implement hash

* fix flake8 error

* Update hashes/djb2.py

* Update hashes/djb2.py

* Long lines

* def djb2(s: str) -> int:

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-16 22:22:47 +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
bnMikheili
55b3088e47
Hash adler32 (#2111)
* implement hash

* fix indentation
2020-06-14 09:49:39 +02:00
bnMikheili
ec2d900b03
implement sdbm hash algorithm (#2094)
* implement sdbm hash algorithm

* fix bug: styling

* fix styling for decimal_to_any
2020-06-11 22:22:16 +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
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
7b7c1a0135
Fixes unused variable errors in LGTM (#1746)
* Fixes unsed variable errors in LGTM

* Fixes integer check

* Fixes failing tests
2020-02-11 13:59:09 +05:30
Christian Clauss
670f952aa6
Travis CI: Don’t allow bare exceptions (#1734)
* Travis CI: Don’t allow bare exceptions

* fixup! Format Python code with psf/black push

* except IOError:

* except IOError:

* Update hamming_code.py

* IndexError

* Get rid of the nonsense logic

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-02-07 22:02:08 +02:00
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
Christian Clauss
28419cf839 pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
2020-01-03 22:25:36 +08:00
João Gustavo A. Amorim
3cfca42f17 add the index calculation class at digital_image_processing and the hamming code algorithm at hashes (#1152)
* add the index calculation at difital_image_processing file

* make changes at index_calculation

* update the variables to self variables at functions

* update the word wrap in comments at index_calculation

* add the hamming code algorithm

* Wrap long lines
2019-12-06 07:13:10 +01: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
QuantumNovice
d21b4cfb48 Added pytests to hashes/md5.py (#1100)
* Added pytests to sha1.py

* tweaking md5

* Added Pytests to hashes/md5.py
2019-08-06 13:16:30 +02:00
QuantumNovice
47bc34ac26 Added pytests to sha1.py (#1098) 2019-08-06 02:06:15 +02:00
Shahabaldin Mohammadi
9532492728 added enigma machine algorithm (#932) 2019-07-07 12:19:15 +05:30
Mickaël Schoentgen
2d70e9f747 Fix ResourceWarning: unclosed file (#681)
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
2019-01-08 16:59:23 +08:00
piyush-kgp
59027e4bd5 Improved code documentation, removed uncalled function 2018-09-25 22:56:24 +05:30
piyush-kgp
965fdee22d SHA1 class completed, Test passed 2018-09-25 19:21:29 +05:30
piyush-kgp
7f3895cdaf moved constants inside the class 2018-09-23 19:44:37 +05:30
piyush-kgp
4d255f4e9f SHA1 skeleton code 2018-09-23 05:25:07 +05:30
cclauss
bec160c6dc
Use strip() to deal with leading or trailing whitespace 2018-07-03 08:33:38 +02:00
cclauss
ee3b0f2e50
Properly define raw_input)( in Python 3
__raw_input()__ was removed in Python 3 in favor of __input()__.  This change ensure similar functioning in both Python 2 and Python 3.
2018-07-02 10:11:28 +02:00
Christian Bender
dbfc220264
Merge pull request #294 from TheAlgorithms/documented_md5_hash
Documented md5 hash
2018-04-16 14:19:31 +02:00
Christian Bender
0494d48f84 added a docstring 2018-04-16 14:18:23 +02:00
Christian Bender
cfae621f46 I documented the md5 hash 2018-04-16 14:13:49 +02:00
Christian Bender
c1422ec99c fixed the assert statments 2018-04-16 13:42:44 +02:00
Christian Bender
3a7e75f329 added a option for termination the program 2018-04-16 13:37:04 +02:00
cclauss
4e06949072 Modernize Python 2 code to get ready for Python 3 2017-11-25 10:23:50 +01:00
Maciej A. Czyzewski
123b8a30ad added simple chaos machine impl. to hashes/ 2017-10-14 15:46:59 +02:00
naveenarun
0e60a18cfa fix python3 print statement 2016-09-16 14:32:41 -05:00