Commit Graph

3068 Commits

Author SHA1 Message Date
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
cclauss
0f229e0870 Atbash.py: Both raw_input() and unichr() were removed in Python 3 (#855)
* Atbash.py: Both raw_input() and unichr() were removed in Python 3

@sateslayer and @AnupKumarPanwar your reviews please.

* Remove any leading / trailing whitespace from user input
2019-06-05 09:09:04 +08:00
Guo
f9b8dbf9db Correct the wrong iterative DFS implementation (#867)
* Update DFS.py

* Update DFS.py
2019-06-04 16:34:28 +08:00
John Law
c2552cdfcd Create CONTRIBUTING.md (#864)
* Create CONTRIBUTING.md

* Create a tailor-made contribution guide

Closes #802

* Update README.md

* Rename License to LICENSE.md
2019-06-02 12:14:18 +08:00
luanjerry
f386fce820 Update queue_on_list.py (#851)
* Fixed error in queue_on_list.py
2019-05-31 16:05:24 +08:00
Dave Kerr
4d9a1611bd implementations may be *less* efficient than python standard libs (#854) 2019-05-31 16:03:55 +08:00
Sven Efftinge
aeab9f1068 Added gitpod info (#848) 2019-05-31 16:02:56 +08:00
cedricfarinazzo
9037abae11 Fix spelling in neural_network/convolution_neural_network.py (#849)
* Fix spelling in neural_network/convolution_neural_network.py

* fix import

Signed-off-by: cedric.farinazzo <cedric.farinazzo@epita.fr>
2019-05-30 08:47:00 +08:00
Erfan Alimohammadi
fc95e7a91a Fermat's little theorem (#847)
* Fix typo

* Add fermat's little theorem

* Update fermat_little_theorem.py

* Fix comments

* Add Wikipedia reference
2019-05-28 20:51:48 +08:00
alpylmz
dd62f1b802 Create sol5.py (#425)
added a solve for the problem
2019-05-26 23:34:49 +05:30
Anup Kumar Panwar
f56dd7f8e3
Update Atbash.py 2019-05-26 22:59:07 +05:30
Anup Kumar Panwar
cb4be75941
Rename nqueens.py to n_queens.py 2019-05-26 22:21:22 +05:30
victoni
559951c181 Lucas series added (#399) 2019-05-26 22:12:55 +05:30
Bruno Santos
89f15bef0a Create prim.py (#397) 2019-05-26 22:11:46 +05:30
Shubhayu Das
5be32f4022 Add files via upload (#396) 2019-05-26 22:10:04 +05:30
Ambuj81
7f4f565e62 subset_generation (#326)
* subset_generation

generate all possible subset of size n of a given array of size r

* Rename subset_generation to subset_generation.py

* Update subset_generation.py

I made all changes I could  . What I mean is I removed all the empty space ....... 
There some comment extra if you feel removing those comments please do so yourself pls provide spacing as it should be

* Create morse_Code_implementation.py

* Any more changes pls let me know
2019-05-26 22:07:40 +05:30
CHIANGTUNGHUA
974088d872 Update .gitignore (#841) 2019-05-26 22:03:53 +05:30
Anup Kumar Panwar
71be23999c refactor 2019-05-26 21:56:10 +05:30
Ayman Mohamed Ali
3033c1e06e Implement check_bipartite_graph using DFS. (#836) 2019-05-26 18:16:45 +05:30
Anup Kumar Panwar
23938708ac
Update README.md 2019-05-26 17:11:41 +05:30
Artyom Belousov
94380a17a8 Added treap (#797)
* Added treap

* Added comments to treap
2019-05-26 06:20:37 +08:00
Mehdi ALAOUI
02c0daf9e5 Adding unit tests for sorting functions, and improving readability on some sorting algorithms (#784)
* Adding variable to fade out ambiguity

* More readability on merge sorting algorithm

* Updating merge_sort_fastest description and explaining why

* Adding tests file with imports

* Standardazing filenames and function names

* Adding test cases and test functions

* Adding test loop

* Putting 'user oriented code' inside main condition for having valid imports

* Fixing condition

* Updating tests: adding cases and todo list

* Refactoring first euler problem's first solution
2019-05-25 21:41:24 +08:00
José Henrique Ivanchechen
9f982a83c8 add pigeon hole sort (#833) 2019-05-24 22:46:39 +05:30
BruceLee569
a0ab3ce098 Update quick_sort.py (#830)
Modify the list comprehensions to reduce the number of judgments, the speed has increased by more than 50%.
2019-05-24 23:54:03 +08:00
Níkolas Vargas
023f5e092d fix empty list validation and code data structures (#826)
* fix empty list validation and code data structures

* Update bucket_sort.py

https://github.com/TheAlgorithms/Python/pull/826#pullrequestreview-240357549
2019-05-22 20:09:36 +08:00
Anirudh Ajith
b5667e5ee9 Removed the (incorrectly named) redundant file graph_list.py and renamed graph.py to graph_list.py (#820) 2019-05-21 14:06:05 +08:00
Adam
c1130490d7 fix spelling on line 44 of bucket sort (#824)
* change besd to best
2019-05-20 21:22:20 +08:00
DaveAxiom
316d5ffa37 Add NQueens backtracking search implementation (#504) 2019-05-20 04:36:46 +08:00
Andy Lau
f5abc04176 Update bucket_sort.py (#821)
* Some simplification
2019-05-19 17:00:54 +08:00
weixuanhu
b6c3fa8992 Interpolation search - fix endless loop bug, divide 0 bug and update description (#793)
* fix endless loop bug, divide 0 bug and update description

fix an endless bug, for example, if collection = [10,30,40,45,50,66,77,93], item = 67.

fix divide 0 bug,  when right=left it is not OK to point = left + ((item - sorted_collection[left]) * (right - left)) // (sorted_collection[right] - sorted_collection[left])

update 'sorted' to 'ascending sorted' in description to avoid confusion

* delete swap files

* delete 'address' and add input validation
2019-05-18 10:59:12 +08:00