Commit Graph

3415 Commits

Author SHA1 Message Date
Aman Gupta
ba8b156fdc
Iterative merge sort implementation (#1972)
* Added Iterative merge sort

* Added iterative merge sorts

* Update changes

* Add the ability to sort strings

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-11 16:40:02 +02:00
halilylm
1151d8b157
Add type hints to max_heap.py (#1960)
* Max heap implementation

* Update max_heap.py

* Update max_heap.py

* Update max_heap.py

* __len__ method added

* Update max_heap.py

Co-authored-by: halilpython <65048618+halilpython@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-11 12:23:39 +02:00
Christian Clauss
a7cd633bb6
Fix astar (#1966)
* Fix astar

Single character variable names are old school.

* fixup! Format Python code with psf/black push

* Tuple

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-10 20:49:40 +05:30
Christian Clauss
3d9bb051a8
Travis CI: Strict flake8 (#1962)
* Travis CI: Strict flake8

Turn the screws all the way down.

* updating DIRECTORY.md

* Switch from flake8 --select to --ignore

* Quotes

* IGNORE=E123,E203,E265,E266,E302,E401,E402,E712,E731,E741,E743,F811,F841,W291,W293,W503

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-10 08:06:42 +02:00
Jeffin Francis
77c3e5b74b
Added A* algorithm (#1913)
* a* algorithm

* changes after build error

* intent changes

* fix after review

* ImportMissmatchError

* Build failed fix

* doctest changes

* doctest changes
2020-05-10 00:37:36 +05:30
Raj-Parekh24
eef6393935
Kadanes_algorithm (#1959)
* Add files via upload

* Update Kadane's_algorithm.py

* Update and rename Kadane's_algorithm.py to kadanes_algorithm.py

* Update kadanes_algorithm.py

* Update kadanes_algorithm.py

* Update kadanes_algorithm.py

* Update kadanes_algorithm.py

* Update kadanes_algorithm.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-09 21:00:59 +02:00
Christian Clauss
8b55a143fa
Travis CI: lint for useless backslashes (#1961)
* Travis CI: lint for useless backslashes

* updating DIRECTORY.md

* flake8  --max-complexity=25

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-09 13:24:25 +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
mateuszz0000
c18c677a38
Added Nearest neighbour algorithm (#1934) 2020-05-07 23:47:28 +02:00
siva1098
7469fb6edd
Add graphs/frequent_pattern_graph_miner.py (#1866)
* Add files via upload

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update graphs/frequent_pattern_graph_miner.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Update frequent_pattern_graph_miner.py

* Whitespace changes

* Format with psf/black

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 23:30:24 +02:00
Arvind Krishna
9e5f365fed
Add sleep-sort (#1867)
* added sleepsort

Adding sleepsort

* Add doctest and typing for sleepsort

* Use self-descriptive variable name

* Update sleepsort.py

* Update sorts/sleepsort.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 21:44:34 +02:00
pharshil1902
a52dd66ac6
Added Shortest Job First Algorithm (#1957)
* Added Shortest Job First Algorithm

It is in IPYNB format but the dataframes are really looking good.
Please, take a look.

* Delete Shortest_Job_First_Algorithm.ipynb

* Added Shortest Job First Algorithm

* Update Shortest_Job_First Algorithm.py

* Update Shortest_Job_First Algorithm.py

* Update Shortest_Job_first Algorithm

* Added Shortest_Job_First Algorithm

* Added Shortest Job First Algorithm

* Update shortest_job_first_algorithm.py

* Format code with psf/black

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 19:27:44 +02:00
Jeffin Francis
8a8527f1bd
Added Lstm example for stock predection (#1908)
* Added Lstm example for stock predection

* Changes after review

* changes after build failed

* Add Kiera’s to requirements.txt

* requirements.txt: Add keras and tensorflow

* psf/black

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-07 08:53:44 +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
Vipul Rai
3d4ccc383a
change method name from front to get_front (#1943)
Co-authored-by: “Vipul <“vipulrai8891@gmail.com”>
2020-05-06 11:19:44 +05:30
Christian Clauss
08c8bb5ad5
Deal with maps (#1945)
* Deal with maps

Try with the search term "pizza" to see why this was done in #1932

* fixup! Format Python code with psf/black push

* Update armstrong_numbers.py

* updating DIRECTORY.md

* Update crawl_google_results.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-06 03:32:40 +02:00
Sanders Lin
1e84aabaea
Create sol2.py (#1876)
* Create sol2.py

* updating DIRECTORY.md

* Update DIRECTORY.md

* updating DIRECTORY.md

* Update sol2.py

* Update DIRECTORY.md

* updating DIRECTORY.md

* Improve docstrings

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: vinayak <itssvinayak@gmail.com>
Co-authored-by: John Law <johnlaw@linux.com>
2020-05-05 17:27:18 +02:00
Anup Kumar Panwar
540023ec31
Delete FUNDING.yml 2020-05-04 11:18:41 +05:30
Christian Clauss
d1b25760bc
Fix psf/black issues than fail the build (#1935)
* Fix psf/black issues than fail the build

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-03 23:58:44 +02:00
Alok Shukla
9b2d65bac1
Solution for Euler Problem 26 (#1939)
* Solution for Euler Problem 26

* Update project_euler/problem_26/sol1.py

typo error fix.

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

* Update project_euler/problem_26/sol1.py

typo error fix

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

* Update project_euler/problem_26/sol1.py

ok to remove, this comes from Pycharm automatically when docstring is added.

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

* Update project_euler/problem_26/sol1.py

ok to remove.

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

* Update project_euler/problem_26/sol1.py

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

* Update project_euler/problem_26/sol1.py

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

* Update project_euler/problem_26/sol1.py

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

* now_divide = now_divide * 10 % divide_by_number

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-03 22:48:16 +02:00
Akash
f80ffe1f54
added method for checking armstrong number (#1936)
* added method for checking armstrong number

* Update comment

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-03 19:56:33 +02:00
Akash
b6fcee3114
Check if a item exist in stack or not (#1931)
* Check if a item exist in stack or not

* implemented __contains__ method in stack

* made changes in __contains__
2020-05-03 16:15:31 +02:00
lanzhiwang
853741e518
enhanced segment tree implementation and more pythonic (#1715)
* enhanced segment tree implementation and more pythonic

enhanced segment tree implementation and more pythonic

* add doctests for segment tree

* add type annotations

* unified processing sum min max segment tre

* delete source encoding in segment tree

* use a generator function instead of returning

* add doctests for methods

* add doctests for methods

* add doctests

* fix doctest

* fix doctest

* fix doctest

* fix function parameter and fix determine conditions
2020-05-02 21:44:29 +02:00
QuantumNovice
9bb57fbbfe
support_vector_machines.py increase error tolerance to suppress convergence warnings (#1929)
* Update support_vector_machines.py

* Update support_vector_machines.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-02 21:19:45 +02:00
Saba Pochkhua
a859934105
Hamiltonian Cycle (#1930)
* add skeleton code

* add doctests

* add tests for util function + implement wrapper

* full implementation

* add ability to add starting verex for algorithm

* add static type checking

* add doc tests to validation method

* bug fix: doctests expected failing

* Update hamiltonian_cycle.py

* Update hamiltonian_cycle.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-02 21:13:56 +02:00
lkdmttg7
d62cc35268
Update stale comment (#1924)
* Update close comment

* Update stale.yml

* Multiline strings in yaml files

https://yaml-multiline.info/

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-02 13:04:25 +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
QuantumNovice
bcaa88b26c
Changed the deprecated np.matrix to np.ndarray (#1923) 2020-05-01 17:42:41 +02:00
Sanders Lin
308505f18f
Add shortest path by BFS (#1870)
* Create breadth_first_search_shortest_path.py

* updating DIRECTORY.md

* Reduce side effect of `shortest_path`

For the sake of future testing and documentation -

* fixup! Format Python code with psf/black push

* Fix typo `separately`

* Change to get() from dictionary

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Move graph to the top

* fixup! Format Python code with psf/black push

* Add doctest for shortest path

* Add doctest for BFS

* fixup! Format Python code with psf/black push

* Add typings for breadth_first_search_shortest_path

* fixup! Format Python code with psf/black push

* Remove assert from doctests

* Add blank line to doctest

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw@linux.com>
2020-05-01 07:24:32 +02:00
Saba Pochkhua
b01e5b78a3
Graph coloring (#1921)
* add skeleton code

* add doctests

* add mainc function pseudo code and tests (ToDo: write Implementation)

* typo fixes

* implement algorithm

* add type checking

* add wikipedia link

* typo fix

* update range syntax

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

* change indexed iteration checking to any()

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

* fix: swap import and documentation sections

* fix: change return none to return empty list

* remove unnecessary import (Union)

* change: remove returning boolean indicating problem was solved or not

* remove unnecessary import (Tuple)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-30 23:23:52 +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
mateuszz0000
3d0680eddf
Added Burkes dithering algorithm. (#1916)
* Added Burkes dithering algorithm

* Added unit tests for burkes algorithm

* Fix burkes algorithm

* Added some additional information

* Fixed CI tests

* Update digital_image_processing/dithering/burkes.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update digital_image_processing/dithering/burkes.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update digital_image_processing/dithering/burkes.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Propogate the += and add a doctest

* Fix doctest

* @staticmethod --> @ classmethod to ease testing

* def test_burkes(file_path):

* Fix for mypy checks

* Fix variable order in get_greyscale

* Fix get_greyscale method

* Fix get_greyscale method

* 3.753

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-30 11:54:20 +02:00
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
8cb957f893
Blacken one_dimensional.py (#1911)
* Blacken one_dimensional.py

* updating DIRECTORY.md

* Travis CI: Upgrade to Ubuntu 20.04 LTS Focal

Ubuntu 20.04 LTS (Focal Fossa) https://releases.ubuntu.com/focal

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-27 18:40:46 +02:00
8Dion8
0ef9dd3977
Create one_dimensional.py (#1905)
* Create one_dimensional.py

* Update cellular_automata/one_dimensional.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update cellular_automata/one_dimensional.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update one_dimensional.py

Moved import to the top so that the type Image gets recognized

* Update one_dimensional.py

* Update cellular_automata/one_dimensional.py

* Update cellular_automata/one_dimensional.py

* Update one_dimensional.py

* Update one_dimensional.py

* Update one_dimensional.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-27 18:07:31 +02:00
mateuszz0000
5933cd4d83
Added sepia tone (#1877)
* Add sepia tone

* Add unit test

* technic --> technique

* Update digital_image_processing/sepia.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update digital_image_processing/sepia.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Fixed errors after commit changes

* Fixed errors

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-26 11:59:11 +02:00
Sanders Lin
e5dd2b1eb7
Fix typo in Project Euler sol1.py (#1875) 2020-04-25 23:27:01 +02:00
Prince Gangurde
58271c5851
Update linear_search.py (#1906) 2020-04-24 12:34:18 +02:00
Christian Clauss
b560b76002
Add cellular_automata directory (#1902)
Related to https://github.com/TheAlgorithms/Python/issues/1613#issuecomment-618175224 @8Dion8 Your review please.  Once this land, this directory would be a great place for you to add your work.
2020-04-23 11:57:32 +02:00
Arkadip Bhattacharya
098be3594b
fix: space count in strings/word_occurrence.py (#1896)
* fix: space count in strings/word_occurrence.py

* Update strings/word_occurrence.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update strings/word_occurrence.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update strings/word_occurrence.py

Co-Authored-By: Christian Clauss <cclauss@me.com>

* Update word_occurrence.py

Seems like, there is no need o `occurrence.pop('', None)`

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-21 17:28:54 +02:00
Christian Clauss
24b2aecef3
Create Python/bit_manipulation/README.md (#1897)
* Create Python/bit_manipulation/README.md

To open up a new area of algorithms...

@Shrutikabansal I hope that you will contribute some of your work here.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-20 20:19:27 +02:00
Muhammad Umer Farooq
4b78c6952d
Create is_palindrome.py (#1754)
* Create is_palindrome.py

* Update is_palindrome.py

* Update is_palindrome.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-19 22:05:36 +05:30
Sanders Lin
c92a520956
Update breadth_first_search.py (#1869) 2020-04-19 19:26:52 +05:30
Sanders Lin
7aaf79cc23
Initialize set with source in DFS (#1872)
* Update dfs.py

* Add type hints, rearrange doc-strings and comments

* fixup! Format Python code with psf/black push

* dfs -> depth_first_search

Co-Authored-By: Christian Clauss <cclauss@me.com>

* dfs -> depth_first_search

* Add doctest for DFS

* fixup! Format Python code with psf/black push

* Rename dfs.py to depth_first_search_dictionary.py

* updating DIRECTORY.md

* Rename depth_first_search_dictionary.py to depth_first_search_dfs.py

* updating DIRECTORY.md

* Rename depth_first_search.py to depth_first_search_2.py

* updating DIRECTORY.md

* Rename depth_first_search_dfs.py to depth_first_search.py

* updating DIRECTORY.md

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-17 20:05:29 +02:00
Sanders Lin
1c9d4a3929
Update abbreviation.py (#1887) 2020-04-17 20:04:30 +02:00
Sanders Lin
0feed0bfb8
Update CONTRIBUTING.md (#1886) 2020-04-17 20:03:36 +02:00
Prince Gangurde
8c01da20d6
Update random_forest_regressor.py (#1880) 2020-04-17 12:43:50 +02:00
Christian Clauss
d48661e35d
CONTRIBUTING.md: What is an Algorithm? (#1885)
* CONTRIBUTING.md: What is an Algorithm?

We are seeing too many _how-to examples_ for using existing Python packages so we should define what we want algorithm contributions to be.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-17 12:42:00 +02:00
Prince Gangurde
b64c4af296
Create gaussian_naive_bayes.py (#1861)
* Create Gaussian_Naive_Bayes.py

Added Gaussian Naive Bayes algorithm in the module machine learning

* Rename Gaussian_Naive_Bayes.py to gaussian_naive_bayes.py

* requirements.txt: pip install xgboost

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-04-17 09:38:44 +08:00
Sanders Lin
d2e8e6215e
Update g_topological_sort.py (#1873) 2020-04-16 12:34:14 +02:00