Commit Graph

122 Commits

Author SHA1 Message Date
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
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
vinayak
2d3d660155
black fixes and Travis CI fixes (#2160)
* black format

* updating DIRECTORY.md

* fixes

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-02 20:02:15 +05:30
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
mateuszz0000
965d02ad41
Update atbash cipher (doc, doctest, performance) (#2017)
* Update atbash

* Add benchmark() to quantify the performance improvement

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-20 08:23:17 +02:00
Christian Clauss
38d2e98665
hill_cipher.py: gcd() -> greatest_common_divisor() (#1997)
* hill_cipher.py: gcd() -> greatest_common_divisor()

* fixup! Format Python code with psf/black push

* import string

* updating DIRECTORY.md

* Change matrix to array

Add more tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-05-18 13:05:51 +02:00
Bharath kumar Reddy Kotha
aa120cea12
Add tests and type hints to hill cipher (#1991)
* Added tests and type hints to hill cipher

* Remove extra >>>

* import doctest

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-05-18 09:03:20 +02:00
Maxim R
369562a1e8
Upgrades to caesar_cipher.py (#1958)
* Added more flexibility to functions, decreased amount of repeating code

* Added docstrings

* Updated input functions

* Added doctests

* removed test piece of code

* black .

* Updated caesar cipher standard alphabet to fit python 3.8

* Update and rename sleepsort.py to sleep_sort.py

* Or 4

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-08 07:44:07 +02:00
Maxim R
4acc28ba55
Added new algorithm: cracking caesar cipher with the chi-squared test (#1950)
* added decrypt_caesar_with_chi_squared.py and ran all checks

* Updated default parameters

Removed mistake with mutable default arguments

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

* Updated handling for optional arguments

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

* Changed return statement to tuple

Made function return a tuple instead of a list

* Added more doctests

* Fixed spelling mistakes

* black . - reformatted decrypt_caesar_with_chi_squared.py

* Updated if statements to fit the updated code

* Minimized amount of lines in the code.

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-06 19:42:18 +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
Christian Clauss
1ad78b2663
Fix invalid escape sequence in binary_search_tree.py (#1920)
* Fix invalid escape sequence in binary_search_tree.py

data_structures/binary_tree/binary_search_tree.py:156
  /home/travis/build/TheAlgorithms/Python/data_structures/binary_tree/binary_search_tree.py:156: DeprecationWarning: invalid escape sequence \

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 02:17:11 +05:30
LethargicLeprechaun
fbc038d532
Added A1Z26 Cipher (#1914)
* A1Z26 Cipher

* A1Z26 Cipher

* Added type hints

* Added Doctests

* removed tabs, spaces instead

* corrected doctest

* corrected doctest

* info URLs added

* Condensed decode to one line

* Condensed encode function to a single line

* Nice one!

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-30 00:23:51 +02:00
Christian Clauss
b1377f0e57
autoblack: actions/checkout@v1 # Use v1, NOT v2 (#1796)
* autoblack: actions/checkout@v1  # Use v1, NOT v2

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-03-13 09:23:38 +01:00
Aakash Dinkar
182e3042f8
update rot13.py (#1790)
* update rot13.py

* Update rot13.py

* Type hints, doctests, URL to Wikipedia

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-03-08 07:04:21 +01: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
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
tania-cmyk
74a7b5f799
relevant documentation added (#1725) 2020-02-03 14:30:58 +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
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