Commit Graph

2305 Commits

Author SHA1 Message Date
PatOnTheBack
2ad5be9919 Modified Docstrings to Fix Errors (#975)
I modified the Docstrings at the beginning of the file to fix D400, W0105, and E402.
2019-07-10 22:00:30 +02:00
Shoujue Xu
34dee749a7 add canny edge detection algorithm and modify sobel_filter (#991)
* add gaussian filter algorithm and lena.jpg

* add img_convolve algorithm and sobel_filter

* add canny edge detection algorithm and modify sobel_filter

* format to avoid the backslashes
2019-07-10 22:41:05 +08:00
PatOnTheBack
add1aef064 Rename average.py to average_mean.py (#939)
'average.py' is ambiguous. There are several kinds of averages, so 'average_mean.py' is a more precise name.
2019-07-10 07:21:04 +02:00
cclauss
e6eaa078e2
Pytest the entire repo (#980)
* Pytest the entire repo

* Do each directory for now...

* YAML files hate tabs

* Add more requirements

* pip install opencv-python

* Comment out FTP

* Add pandas and sklearn to requirements

* Comment out FTP, graphs, machine_learning, maths, neural_network, project_euler

* Update .travis.yml

* Comment out Data structures

* if __name__ == "__main__":

* pytest --ignore=

* pytest .

* Update .travis.yml

* pytest . --doctest-modules --ignore=${IGNORE}

* Ignore --ignore because it just hangs
2019-07-10 06:59:39 +02:00
Dharni0607
c85312da89 updates in closest pair of points algorithm (#979)
* updated closest pair of points (n*(logn)^2) to (n*logn)
2019-07-09 19:50:43 +04:30
Jasper
8b2d1b7f50 added decimal to hexadecimal conversion (#977)
* added decimal to hexadecimal conversion

* fixed error occuring as more digits were needed
2019-07-09 09:03:18 +02:00
Shoujue Xu
e2d9953952 convolve and sobel (#971)
* add gaussian filter algorithm and lena.jpg

* add img_convolve algorithm and sobel_filter
2019-07-08 22:56:26 +05:30
Animesh Singh
32d5c1a9b2 Project Euler Problem #13 Python Solution (#935)
* Create text file for numbers

* Create sol2.py

* Pythonic version of Problem #16 solution

* Update sol2.py

* Valid Python code for Python version 2-3

* Update sol2.py
2019-07-09 00:58:58 +08:00
cclauss
78cd3df3fc Update CONTRIBUTING.md to match #964 (#969)
* Update CONTRIBUTING.md to match #964

Blocked by #964

* Do not modify README or DIRECTORY file.

* Update CONTRIBUTING.md
2019-07-08 23:38:47 +08: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
PatOnTheBack
2b365284c8 Removed Unnecessary Assignment for 'error' Var (#920)
`error = abs(f(a))` was declared on line 24 and line 32. It is unnecessary to have in both places.
I removed the second instance since it wastes resources to keep redefining the variable inside the for loop.
This fixes an [issue found by lgtm](66c4afbd0f/files/maths/newton_raphson.py)
2019-07-07 23:45:42 +08:00
Hector S
234b0a77c4 Simplied password_generator.py (#968)
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory

* Removed .vs/ folder per #893

* Rename matrix_multiplication_addition.py to matrix_operation.py

* Added main() function and simplified password generation.

* Modified password_generator.py file according to suggestions in #968
2019-07-07 17:17:38 +02:00
Shahabaldin Mohammadi
9532492728 added enigma machine algorithm (#932) 2019-07-07 12:19:15 +05:30
Aditi Agarwal
4ff2a9dd4e minimax (#947)
* minimax.py

minimax algorithm is used for game like tic tac toe. It traces the path and selects the optimal move.

* minimax.py

Minimax is used in decision making and game theory to find the optimal move for a player, when your opponent also plays optimally. It is widely used in games like Tic-Tac-Toe, Chess.

* Delete minimax.py

* Update minimax.py

* Minimax is a backtracking algorithm that is used in game theory to find the optimal move for a player, assuming that your opponent also plays optimally
2019-07-07 06:59:58 +02:00
PatOnTheBack
26df2aab1e Removed Unused import sys (#922)
I removed `import sys` because it is not used in the program.
This addresses a [recommendation from lgtm](66c4afbd0f/files/ciphers/caesar_cipher.py)
2019-07-06 23:35:12 +08:00
Erfan Alimohammadi
69bed59036
Fix backtrack time complexity (#965)
* Update backtracking/all_permutations.py
2019-07-06 20:01:52 +04:30
Erfan Alimohammadi
781b7f86e7 Fix readme and duplicate (#967)
* Fix typo

* Add all_permutations algorithm to backtracking directory

* Update backtracking and D&C algorithms in README

Update backtracking and divide_and_conquer algorithms in README

* Remove the duplicated file
2019-07-06 20:02:06 +05:30
Erfan Alimohammadi
839160f83a Generate all permutations of a sequence, using backtracking (#962)
* Fix typo

* Add all_permutations algorithm to backtracking directory
2019-07-06 16:19:36 +03:00
Erfan Alimohammadi
cc4cf3ece7
Generate all subsequences using backtracking (#961)
* Add all_subsequences to backtracking directory
2019-07-06 17:43:50 +04:30
Anup Kumar Panwar
1951b4ca79
Update FUNDING.yml 2019-07-06 14:04:27 +05:30
Anup Kumar Panwar
aa663037f6
Create FUNDING.yml 2019-07-06 13:47:56 +05:30
Anup Kumar Panwar
1161393b39 updated CONTRIBUTING.md 2019-07-06 11:21:08 +05:30
Anup Kumar Panwar
b23834062c refactor 2019-07-06 11:14:55 +05:30
Anup Kumar Panwar
f30f8493e6 Updated README 2019-07-06 11:12:26 +05:30
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
Hetal Kuvadia
831558d38d #945 Backtracking Algorithms (#953)
* Adding nqueens.py for backtracking

* Adding sum_of_subsets.py for backtracking

* Update nqueens.py

* Rename nqueens.py to n_queens.py

* Deleting /other/n_queens.py
2019-07-05 14:18:36 +05:30
Dhandarah
afb98e6c23 KNN (#944)
Creates an example of KNN algorithm using sklearn library.
2019-07-05 14:17:18 +05:30
Jarred Allen
506bb5ccfe Add Red-Black Binary Search Trees (#954)
* Wrote most of an rbt, missing just removal

* Added some convenience methods.

* Added a color method

* Wrote code to delete, but has issues :(

* Fixed a bug in Red-Black trees

* Fixed bug in tree color validation and delete repairing

* Clean up == comparison to None
2019-07-05 14:13:16 +05:30
PatOnTheBack
1c9d995b9e Implement Three New Algorithms (#948)
* Create average_median.py

I created a program to calculate the median of a list of numbers.

* Changed Odd to Even in String

* Create decimal_to_binary.py

- Added 'conversions' folder.
- Created a decimal to binary converter.

* Implemented Decimal to Octal Algorithm

- I created a decimal to octal converter based on the converter in the TheAlgorithms/Python project.
- I added two newlines to make the output of decimal_to_binary.py better.
2019-07-05 14:06:48 +05:30
PatOnTheBack
217615abf6 Removed Unused Variables (#949)
- Removed two unused variables.
- Changed `a` to `_` since the `a` variable is never used.

This addresses [3 alerts from lgtm](d55bbcd204/files/sorts/Odd-Even_transposition_parallel.py).
2019-07-05 14:04:46 +05:30
Shoujue Xu
408c5deb3a add gaussian filter algorithm and lena.jpg (#955) 2019-07-05 13:50:11 +05:30
Hector S
05fc7f8a33 Added '~script.py' to ignore files and updated DIRECTORY.md (#926)
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory

* Removed .vs/ folder per #893

* Rename matrix_multiplication_addition.py to matrix_operation.py

* Added '~script.py' to ignore files and updated DIRECTORY.md
2019-07-04 23:18:57 +08:00
Dharni0607
035457f569 closest pair of points algo (#943)
* created divide_and_conquer folder and added max_sub_array_sum.py under it (issue #817)

* additional file in divide_and_conqure (closest pair of points)
2019-07-04 12:19:14 +04:30
Ashok Bakthavathsalam
03f9940775 Refactored to one pop() (#917) 2019-07-03 23:31:10 +08:00
cclauss
4fb4cb4fd1 Travis CI: Simplify the testing (#887)
* Travis CI: Simplify the testing

* flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

* python: 3.7

* dist: xenial for python: 3.7

* Delete .lgtm.yml

These changes were created to get around the fact that Travis CI was not enabled on this repo.  Now that Travis is enabled, we can remove these modifications.

The problems are that:
1. [LGTM does not want us running flake8 on their infrstructure](https://discuss.lgtm.com/t/can-i-get-lgtm-to-run-flake8-tests/1445/6) and
2. when we do, it [does not work as expected](https://discuss.lgtm.com/t/tests-are-not-automatically-run-when-lgtm-yml-is-modified/1446/4).
2019-07-03 12:51:03 +05:30
Jigyasa G
65a12fa317 Adding sum of subsets (#929) 2019-07-02 23:23:35 +08:00
Dharni0607
0f56ab5c3c Divide and conquer Algorithms Issue#817 (#938)
* add ons in string directory - Bayer_Moore_Search

* created divide_and_conquer folder and added max_sub_array_sum.py under it (issue #817)
2019-07-02 16:50:25 +04:30
Dharni0607
27a8184ccf add ons in string directory - Bayer_Moore_Search (#933) 2019-07-02 16:49:31 +04:30
PatOnTheBack
a2236cfb97 Improve Formatting and Code Quality (#934)
* Improved Formatting of basic_maths.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed functions to match snake_case.

* Improved Formatting of factorial_python.py

- Added docstrings.
- Improved whitespace formatting.
- Renamed constants to match UPPER_CASE.

* Improved Formatting of factorial_recursive.py

- Improved whitespace formatting to meet PyLint standards.

* Improved Code to Conform to PyLint

- Renamed `max` to `max_num` to avoid redefining built-in 'max' [pylint]
- Removed unnecessary parens after 'while' keyword [pylint]

* Improved Formatting of factorial_recursive.py

- Added docstrings.
- Improved whitespace formatting.
2019-07-02 09:35:43 +05:30
PatOnTheBack
bd4017928e Added Whitespace and Docstring (#924)
* Added Whitespace and Docstring

I modified the file to make Pylint happier and make the code more readable.

* Beautified Code and Added Docstring

I modified the file to make Pylint happier and make the code more readable.

* Added DOCSTRINGS, Wikipedia link, and whitespace

I added DOCSTRINGS and whitespace to make the code more readable and understandable.

* Improved Formatting

* Wrapped comments
* Fixed spelling error for `movement` variable
* Added DOCSTRINGs

* Improved Formatting

* Corrected whitespace to improve readability.
* Added docstrings.
* Made comments fit inside an 80 column layout.
2019-07-01 16:10:18 +08:00
PatOnTheBack
2333f93323 Change Declaration of Var 'j' to None (#921)
Since `j` is redefined before it is used, it makes more sense to declare it with the value `None` instead of `1`.

This fixes a [warning from lgtm](66c4afbd0f/files/other/primelib.py)
2019-06-30 12:41:26 +08:00
BruceLee569
34889fc6d8 Update quick_sort.py (#928)
Use the last element as the first pivot, for it's easy to pop, this saves one element space.
Iterating with the original list saves half the space, instead of generate a new shallow copy list by slice method.
2019-06-28 23:55:31 +08:00
brajesh-rit
be4150c720 Create spiralPrint.py (#844)
* Create spiralPrint.py

* Update spiralPrint.py
2019-06-26 23:57:08 +08:00
wuminbin
b7cff04574 better implementation for midpoint (#914) 2019-06-24 18:11:07 +08:00
zachzhu2016
a212efee5b Corrected wrong Dijkstra priority queue implementation (#909)
* Corrected wrong DFS implementation

* changed list into hash set for dijkstra priority queue implementation.
2019-06-23 23:32:12 +08:00
Adeoti Ayodeji
12a16d63b7 Update average.py (#908)
Reduced lines of code and extra processing on the line: n += 1
2019-06-22 12:42:28 +08:00
StephenGemin
a99acae32d Add docstring and comments per Issue #727 (#895)
I've added comments to make understanding this method a little easier for those that are not familiar.  This should close out #727 .

Other changes:
1. added if __name__ == '__main__' rather than the "# MAIN" comment
2. put in return for distances and vertices.  Previously everything was just printed out, but someone may find it useful to have the algorithm return something.
3. Other PEP8 changes
4.  Added example input and expected output as a check to make sure any future changes will give the same output.
2019-06-18 18:28:01 +08:00
Hector S
b8937364dc Fixed typo and capitalized some words (#900)
File looks more elegant now ;-)
2019-06-18 18:27:08 +08:00
Daniel Xu
ef147484ab Added script for automatically generating DIRECTORY.md (#889)
* Added script for automatically generating DIRECTORY.md

* Sort and list files by alphabetical order

* Rename script.py to ~script.py
2019-06-17 18:17:53 +08:00
zachzhu2016
55e0b0f00a Corrected wrong DFS implementation (#903) 2019-06-17 18:13:36 +08:00