Commit Graph

1214 Commits

Author SHA1 Message Date
Sanders Lin
7a6ebb85a2 Update edit_distance.py (#1001)
added bottom up method.
2019-07-13 09:10:02 +02:00
Sanders Lin
1e0b33d3dd Update 3n+1.py (#996)
* Update 3n+1.py

Made variable names more meaningful and removed nested functions.

* Update 3n+1.py

* Update 3n+1.py

* Update 3n+1.py
2019-07-13 09:04:43 +02:00
obelisk0114
1dc9ec8fb2 Update Bucket Sort time complexity analysis (#918) 2019-07-12 23:16:14 +08:00
FrogBattle
f2eb965604 Update ~script.py (#990)
Changing the boolean expression avoids the use of a continue statement.
This way the code becomes easier/faster to compute on lower level and it has a
better coding style.
2019-07-11 18:21:48 +02:00
Sanders Lin
c2f2fa8b23 Update abs_Min.py (#1004)
* Update abs_Min.py

* Create __init__.py

* Rename abs_Min.py to abs_min.py

* Update abs_min.py
2019-07-11 18:20:41 +02:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
Sanders Lin
b79a197e8c Update abs_Max.py (#997)
* Update abs_Max.py

fix docstring for doctest to work properly (add space after >>>)

* Update abs_Max.py
2019-07-11 06:43:03 +02:00
Sanders Lin
37fbd8ca2e Update average_median.py (#998)
added doctest, fixed TypeError: list indices must be integers or slices, not float error due to number/2 producing float as index.
2019-07-10 22:38:10 +02:00
PatOnTheBack
897f1d0fb4 Improved Formatting and Style of Math Algos (#960)
* Improved Formatting and Style

I improved formatting and style to make PyLama happier.

Linters used:

- mccabe
- pep257
- pydocstyle
- pep8
- pycodestyle
- pyflakes
- pylint
- isort

* Create volume.py

This script calculates the volumes of various shapes.

* Delete lucasSeries.py

* Revert "Delete lucasSeries.py"

This reverts commit 64c19f7a6c.

* Update lucasSeries.py
2019-07-10 22:09:24 +02:00
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