Commit Graph

50 Commits

Author SHA1 Message Date
matkosoric
7f04e5cd34
contribution guidelines checks (#1787)
* spelling corrections

* review

* improved documentation, removed redundant variables, added testing

* added type hint

* camel case to snake case

* spelling fix

* review

* python --> Python # it is a brand name, not a snake

* explicit cast to int

* spaces in int list

* "!= None" to "is not None"

* Update comb_sort.py

* various spelling corrections in documentation & several variables naming conventions fix

* + char in file name

* import dependency - bug fix

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-03-04 13:40:28 +01:00
onlinejudge95
4866b1330b
Fixes black failures from Previous PR (#1751)
* Fixes black failures from Previous PR

* Fixes equality testing alert

* Fixes call to main() alert

* Fixes unused import
2020-02-13 02:19:41 +05:30
onlinejudge95
6fdd53c676
Fixes LGTM issues (#1745)
* Fixes redefinition of a variable

* Fixes implementing __eq__

* Updates docstring
2020-02-10 22:23:19 +01:00
cschuerc
81f077adfc Augment binary search algorithms (#1719) 2020-01-28 22:33:59 +05:30
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Faraz Ahmed Khan
c01d178798 Added implementation for simulated annealing (#1679)
* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Update and rename optimization/hill_climbing.py to searches/hill_climbing.py

* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Rebased

* added simulated annealing.py

* added final comments and test

* black formatted

* restricted search domain

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-17 23:32:06 +01:00
Christian Clauss
1f2b1a88ab Typos in comments in hill_climbing.py (#1667)
* Typos in comments in hill_climbing.py

* fixup! Format Python code with psf/black push
2020-01-08 21:06:53 +08:00
Faraz Ahmed Khan
cbab5f18f1 added hill climbing algorithm (#1666)
* added hill climbing algorithm

* Shorten long lines, streamline get_neighbors()

* Update hill_climbing.py

* Update and rename optimization/hill_climbing.py to searches/hill_climbing.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-01-08 06:00:55 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08:00
percy07
df95f43907 Update quick_select.py (#1523)
* Update quick_select.py

Add Doctests.

* Add typehints

* Don't pre-allocate "smaller" and "larger"
2019-10-30 16:10:30 +01:00
praisearts
7b3d385ad6 create simple binary search (#1430)
* create simnple binary search

#A binary search implementation to test if a number is in a list of elements

* Add .py, format with psf/black, and add doctests
2019-10-24 10:31:58 +02:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Laisha Wadhwa
9c634735d3 added fibonacci_search.py (#1341)
* added fibonacci_search.py

* added Fibonacci_search.py after error handling

* added doctests
2019-10-18 08:10:08 +02:00
Du YuanChao
0da4d0a7f3 make code more readable (#1304) 2019-10-08 13:22:40 +05:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02: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
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
wuminbin
b7cff04574 better implementation for midpoint (#914) 2019-06-24 18:11:07 +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
weixuanhu
7677c37011 update 'sorted' to 'ascending sorted' in comments (#789)
To avoid confusion all 'sorted' to 'ascending sorted' in comments
2019-05-06 17:54:31 +08:00
overclockedllama
dd9f0b3f2e fix comma spelling from coma to comma (#722) 2019-02-27 22:33:29 +08:00
Mickaël Schoentgen
2d70e9f747 Fix ResourceWarning: unclosed file (#681)
Signed-off-by: Mickaël Schoentgen <contact@tiger-222.fr>
2019-01-08 16:59:23 +08:00
Mickaël Schoentgen
6128533319 Fix use of deprecated assertEquals() in tests (#680) 2019-01-06 09:12:17 +08:00
Alex Brown
5f90dfbbe7 fixed file reading name for test_tabu_search.py 2018-10-19 17:40:52 -05:00
Alex Brown
b43864552b .txt instead of .py 2018-10-19 17:38:11 -05:00
Alex Brown
91fccecb56 snake_case all the things 2018-10-19 17:14:25 -05:00
ParthS007
0856a61859 Remove Multiple Unused Imports and Variable 2018-10-18 02:58:57 +05:30
Kelvin Salton do Prado
d2e77b05ef searches: add sentinel linear search algorithm 2018-10-02 00:08:42 -03:00
Harshil
8957cf7ea8
Removed empty lines (255-313)
Lines 255 to 313 were just empty, so removed those lines!
2018-05-21 10:01:44 +02:00
irokafetzaki
35110b6e44 Tabu Search 2018-05-20 02:27:01 +03:00
douly
18907e4a07 fix type error (except an int) in jumpmp_search line 7. 2018-04-13 09:56:40 +08:00
Ant Fitch
53681f199c
Fixed error in binary_search_by_recursion
In binary_search_by_recursion, if you search array for a value that does not exist, you will get this error:
RecursionError: maximum recursion depth exceeded in comparison

To fix this, first check to make sure that the value is between left and right points like this:
    if (right < left):
        return None

A similar construct has already been applied to binary_search, but did not exist in the recursive alternative.
2018-01-30 18:50:07 -08:00
cclauss
4e06949072 Modernize Python 2 code to get ready for Python 3 2017-11-25 10:23:50 +01:00
Harshil
7f87515836
Merge pull request #159 from Deepak345/master
implemented jump search
2017-11-03 16:07:43 +05:30
Harshil
8ae1f24465 Merge pull request #151 from DTBUday/master
Added Ternary Search Algorithm
2017-10-19 09:36:32 +05:30
Sarbajit Saha
6d192700c6 added interpolation search 2017-10-15 21:41:10 +05:30
Sarbajit Saha
d70b9268fe fixed spelling of coma to comma 2017-10-15 21:25:54 +05:30
Sachin Arora
85c1e03b63 Merge pull request #149 from KyleScharnhorst/master
Fix: typo in multiple files.
2017-10-13 21:32:42 +05:30
nandujkishor
e0211794da Changed the typographical error (#132)
Changed the typo in line 113 and 115 regarding recursive binary search algorithm, found by a user who commented in comments.
2017-10-13 20:33:40 +05:30
Deepak345
09131a70a1 implemented jump search 2017-10-12 14:40:15 +05:30
Chetan Kaushik
59fc956456 Merge pull request #153 from fickleEfrit/patch-1
Create quick_select.py
2017-10-10 23:05:55 +05:30
TaylorL19
8f71b30995 Fixed binary search to correctly recurse to left half and right half 2017-10-10 11:57:16 -05:00
fickleEfrit
cb3ff4a8f8 Create quick_select.py 2017-10-09 17:26:27 -04:00
Uday Patel
7447a9f9c7 Added Ternary Search Algorithm 2017-10-09 03:19:39 +01:00
KyleScharnhorst
014786e340 Fix: typo in multiple files. 2017-10-07 06:47:50 -07:00
ZivLi
23ac6bc1b5 Add bin-search implement by recursion 2017-07-05 16:40:18 +08:00
NotAName
7bdcd08996 Fixed typo in linear_search.py
The documentation comment said "binary search", not "linear search"
2016-08-30 21:06:49 +02:00
Sergey Tsaplin
ab2614574e Move files to separate directories 2016-08-01 15:06:53 +05:00