Commit Graph

142 Commits

Author SHA1 Message Date
Caeden Perelli-Harris
f15cc2f01c
Follow Flake8 pep3101 and remove modulo formatting (#7339)
* ci: Add ``flake8-pep3101`` plugin to ``pre-commit``

* refactor: Remove all modulo string formatting

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

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

* refactor: Remove ``flake8-pep3101`` plugin from ``pre-commit``

* revert: Revert to modulo formatting

* refactor: Use f-string instead of `join`

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-16 22:50:11 +02:00
Caeden
c6582b35bf
refactor: Move constants outside of variable scope (#7262)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2022-10-16 15:03:29 +05:30
Caeden
a652905b60
Add Flake8 comprehensions to pre-commit (#7235)
* ci(pre-commit): Add ``flake8-comprehensions`` to ``pre-commit`` (#7233)

* refactor: Fix ``flake8-comprehensions`` errors

* fix: Replace `map` with generator (#7233)

* fix: Cast `range` objects to `list`
2022-10-15 19:29:42 +02:00
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
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
Christian Clauss
b75a7c77f8
pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 (#6245)
* pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0

* pre-commit run --all-files
2022-07-11 10:19:52 +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
lovetodevelop
e5d1ff2ea8
Fix tiny spelling error (#6219) 2022-07-04 00:28:53 +08: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
Shuangchi He
e1ec661d4e
Fix some typos (#6113)
* Fix some typos.

* Update volume.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-05-01 18:44:23 +08:00
Paulo S. G. Ferraz
1400cb86ff
Remove duplicate is_prime related functions (#5892)
* Fixes (#5434)

* Update ciphers.rabin_miller.py
         maths.miller_rabin.py

* Fixing ERROR maths/miller_rabin.py - ModuleNotFoundError and changing project_euler's isPrime to is_prime function names

* Update sol1.py

* fix: try to change to list

* fix pre-commit

* fix capital letters

* Update miller_rabin.py

* Update rabin_miller.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-04-09 01:40:45 +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
Leoriem-code
6314195bb1
Add README files 2/8 (#5766)
* add 5 README files

* empty commit to (hopefully) get rid of the `test-are-failling` label

* Update ciphers/README.md

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

* Update conversions/README.md

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

* Update cellular_automata/README.md

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

* Update computer_vision/README.md

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

* Update conversions/README.md

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

* Update compression/README.md

Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-11 21:39:54 +08:00
Rohan R Bharadwaj
bdd135d403
Split base85.py into functions, Add doctests (#5746)
* Update base16.py

* Rename base64_encoding.py to base64.py

* Split into functions, Add doctests

* Update base16.py
2021-11-02 11:10:25 +01:00
happiestbee
f4fd147d03
Make decrypt_caesar_with_chi_squared work with upper case letters (#5379)
* Fixes: #5323

* Fixes: #5323
2021-10-31 11:46:31 +01:00
Rohan R Bharadwaj
6fcefc0453
Add decode function to base16.py (#5575)
* Add decode function

* Update base16.py

* Update base16.py

* Update base16.py

* Made the line shorter

* Made another line shorter
2021-10-26 15:23:38 +02:00
Erwin Junge
700398ec06
[mypy] annotate ciphers (#5569)
* [mypy] annotate `ciphers`

* Update ciphers/polybius.py

* Update polybius.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-26 12:35:21 +02:00
Vinicius Cordeiro
fc5d29e214
Add Bifid cipher (#5493)
* Add Bifid cipher

* Add missing type hint

* Fix variable names
2021-10-24 22:33:53 +02:00
Rohan R Bharadwaj
2ddd81df21
Remove wrongly placed double qoutes (#5530)
* Update baconian_cipher.py

* Update join.py

* Updated type hint
2021-10-23 01:14:08 +08:00
QuartzAl
d82cf5292f
split into usable functions and added docstrings for base32 cipher (#5466)
* split into usable functions and added docstrings

* Simplified code

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

* Simplified code

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-22 13:14:35 +02:00
Hithru De Alwis
672a0c8816
Fixed Typo (#5477)
Change how many "=" sign to how many "=" signs
2021-10-20 15:34:31 +02:00
Vinicius Cordeiro
4880931c24
Add Polybius cipher (#5409)
* Add polybius cipher

* Fix polybius.py build issues and add test
2021-10-19 08:37:51 +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
Rohan R Bharadwaj
bb37ebbe50
Create baconian_cipher.py (#5251)
* Create baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py

* Update baconian_cipher.py
2021-10-14 16:01:38 +02: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
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
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
Dhruv Manilawala
60895366c0
fix(mypy): type annotations for cipher algorithms (#4306)
* fix(mypy): type annotations for cipher algorithms

* Update mypy workflow to include cipher directory

* fix: mypy errors in hill_cipher.py

* fix build errors
2021-04-04 07:22:12 +02:00
Dhruv Manilawala
14bcb580d5
fix(mypy): Fix annotations for 13 cipher algorithms (#4278)
* Initial fix for mypy errors in some cipher algorithms

* fix(mypy): Update type hints

* fix(mypy): Update type hints for enigma_machine2.py

* Update as per the suggestion

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-03-22 07:59:51 +01:00
CarsonHam
61f3119467
Change occurrences of str.format to f-strings (#4118)
* f-string update rsa_cipher.py

* f-string update rsa_key_generator.py

* f-string update burrows_wheeler.py

* f-string update non_recursive_segment_tree.py

* f-string update red_black_tree.py

* f-string update deque_doubly.py

* f-string update climbing_stairs.py

* f-string update iterating_through_submasks.py

* f-string update knn_sklearn.py

* f-string update 3n_plus_1.py

* f-string update quadratic_equations_complex_numbers.py

* f-string update nth_fibonacci_using_matrix_exponentiation.py

* f-string update sherman_morrison.py

* f-string update levenshtein_distance.py

* fix lines that were too long
2021-02-23 11:23:49 +05:30
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
Abdeldjaouad Nusayr Medakene
110a740d5d
Update ciphers/caesar_cipher.py with type hints (#3860)
* Update caesar_cipher.py

improved for conciseness and readability

* Add type hints

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-12-10 22:55:57 +05:30
Hafidh
ce3ce3f8a8
Replace base64_cipher.py with an easy to understand version (#3925)
* rename base64_cipher.py to base64_encoding.py

* edit base64_encoding.py

* import necessary modules inside doctests

* make it behave like the official implementation

* replace format with f-string where possible

* replace format with f-string

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

* fix: syntax error due to closing parenthese

* reformat code

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-11-25 13:38:02 +01:00
Tan Yong He
9bf7b183e7
Improve Base16 Codebase (#3534)
* Add doctest and remove input() usage

* Apply suggestions from code review

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2020-11-23 13:01:43 +05:30
Dhruv Manilawala
b9b7fffcc2
Move CI tests from Travis to GitHub (#3889)
* Add initial support for moving tests to GitHub

* Add setup Python step in the workflow

* Remove Travis CI config file

* Fix GitHub action file for build to trigger on PR

* Use Python 3.8 as tensorflow is not yet supported

* Fix ciphers.hill_cipher doctest error

* Fix: instagram crawler tests failing on GitHub actions

* Fix floating point errors in doctest

* Small change to test cache

* Apply suggestions from code review

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

* Update instagram_crawler.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-11-19 22:01:31 +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
RadadiyaMohit
2ec3750885
create monoalphabetic cipher (#3449)
* create monoalphabetic cipher

* update file

* update file

* update file

* update file

* update file

* update after testing flake8 on this code

* update file

* update file

* update file

* update file

* update file

* update file
2020-10-17 20:00:46 +02:00
RadadiyaMohit
3bbec1db49
create beaufort cipher (#3206)
* create beaufort cipher

if you like my code, merge it and add the label as `hacktoberfest-accepted`

* update the file

* Update beaufort_cipher.py

* Update beaufort_cipher.py

* update as per black formatter

* Update beaufort_cipher.py

* update the file

* update file

* update file

* update file

* update file
2020-10-17 15:50:53 +02:00
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
Jenia Dysin
9d745b6156
Add typehints ciphers and bool alg (#3264)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Fixed accidental commit of file I have't touched

* fixup! Format Python code with psf/black push

* updating DIRECTORY.md

* updating DIRECTORY.md

* Fixed some suggested coding style issues

* Update rsa_key_generator.py

* Update rsa_key_generator.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-16 14:11:52 +08:00
NAVEEN S R
35eefac359
fixed error (#3281)
this will fix code from randomly throwing `SystemExit: The affine cipher becomes weak when key B is set to 0. Choose different key` exception.
2020-10-14 11:53:37 +02:00
PotatoK123
3859c65995
Added rail fence cipher (#3188)
* Added rail fence cipher

* Update rail_fence_cipher.py

* Update rail_fence_cipher.py
2020-10-12 10:37:45 +05:30
Dhruv
0a42ae9095
Fix all errors mentioned in pre-commit run (#2512)
* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
2020-09-30 10:38:00 +02:00
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
Thomas Voss
e92cd9d5c5
Update morse_code_implementation.py (#2386)
* Update morse_code_implementation.py

Added more characters to MORSE_CODE_DICT for a more complete dictionary.
Split words with "/" instead of a space as is standard.
Fixed bug when encrypting a message with a comma.

* Fixed comment typo
2020-09-25 19:03:15 +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
Hasenn
20e98fcded
Fix some warnings from LGTM (#2420)
* fix assignment of a variable to itself

* Fix unnecessary 'else' clause in loop

* formatting and redundant reasignment fix

* mark unreachable code with a TODO comment

* fix variable defined multiple times

* fix static method without static decorator

* revert unintended autoformatting

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

* revert autoformatting issue

* applied black autoformatting

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-13 10:11:27 +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
TrapinchO
30126c26dd
Added enigma machine emulator (#2345)
* Added Enigma machine file

Added Enigma machine file to 'ciphers' section

* Added doctest to validator

* Fixed typo

* Shortened some lines

* Shortened some lines

* Update enigma_machine.py

* Shortened some lines

* Update enigma_machine.py

* Update enigma_machine.py

* Update enigma_machine2.py

* Update enigma_machine2.py

* added f-strings

* Update enigma_machine2.py

* Update enigma_machine2.py

* Updated some numbers

* Plugboard improvement

Added option to separate pair for plugboard by spaces

* renamed variable

* renamed some variables

* improved plugboard exception

* Update enigma_machine2.py

* Update enigma_machine2.py
2020-08-26 21:52:17 +02:00