Commit Graph

1047 Commits

Author SHA1 Message Date
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
archithadge
6e2fb22f5e Problem 234 project Euler (#883)
* Problem 234 project Euler

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update project_euler/problem_234

Co-Authored-By: Emmanuel Arias <emmanuelarias30@gmail.com>

* Update and rename problem_234 to problem_234.py

* Made suggested changes

else was not required
temp declared afterwards
suggested changes are correct.Thank u!

* Rename project_euler/problem_234.py to project_euler/problem_234/sol1.py
2019-06-16 21:19:20 +08:00
Erfan Alimohammadi
1b3affc2ed fix typo (#902) 2019-06-16 02:07:23 +05:30
StephenGemin
af1925bcd9 Remove empty folder in analysis/compression_analysis (#897)
* Add compression_analysis

removing analysis/compression_analysis to just compression_analysis

* Delete PSNR-example-base.png

* Delete PSNR-example-comp-10.jpg

* Delete compressed_image.png

* Delete example_image.jpg

* Delete example_wikipedia_image.jpg

* Delete original_image.png

* Delete psnr.py
2019-06-12 22:54:30 +08:00
Hector S
05e5172093 .vs/ directory, matrix_multiplication_addition file and binary tree directory (#894)
* 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
2019-06-11 19:24:53 +08:00
guij15
066f37402d Update newton_raphson.py (#891) 2019-06-10 12:16:36 +05:30
StephenGemin
9b945cb2b4 Iterative fibonacci with unittests from slash (#882)
* iterative and formula fibonacci methods

Added two ways to calculate the fibonacci sequence:  (1) iterative  (2) formula.  

I've also added a timer decorator so someone can see the difference in computation time between these two methods.  

Added two unittests using the slash framework.

* Update test_fibonacci.py

* remove inline comments per Contributing Guidelines

* Update sol5.py

* Create placeholder.py

* Update and rename maths/test_fibonacci.py to maths/tests/test_fibonacci.py

* Delete placeholder.py

* Create __init__.py

* Update test_fibonacci.py

* Rename Maths/lucasSeries.py to maths/lucasSeries.py

* Update and rename Project Euler/Problem 01/sol5.py to project_euler/problem_01/sol6.py
2019-06-08 20:25:34 +08:00
CharlesRitter
6e894ba3e8 Odd-Even Transposition Sort (#769)
* -Added a single-threaded implementation of odd-even transposition sort.

This is a modified bubble sort meant to work with multiple processors.
Since this is running on a single thread, it has the same running time
as bubble sort.

* -Added a parallel implementation of Odd-Even Transposition sort

This implementation uses multiprocessing to perform the swaps
at each step of the algorithm simultaneously.
2019-06-07 23:38:43 +08:00
Daniel Xu
ebe227c386 Removed Graphs and move prim.py to graphs (#872)
* Move prim.py from Graphs to graphs

* Removed prim.py from Graphs

* Update prim.py
2019-06-05 09:37:05 +08:00