Commit Graph

1868 Commits

Author SHA1 Message Date
Nika Losaberidze
2264244a34
Add Z-function algorithm implementation (#2067)
* Add Z-function algorithm implementation

* Spelling correction

* Reference url correction

* Add additional function as an example of z-function usage, change docstrings for functions

* Fix flake8 errors

* Update z_function.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-11 19:43:05 +02:00
Vignesh
3893ed30ca
created perfect_cube.py (#2076)
* created perfect_cube.py

To find whether a number is a perfect cube or not.

* Update perfect_cube.py

* Update perfect_cube.py

* Update perfect_cube.py
2020-06-11 19:36:53 +02:00
Kevin C. Escobedo
19c3871b21
Added function to convert from decimal to another base (#2087)
* Added function to convert from decimal to another base

* Update conversions/decimal_to_any.py

Changed type() to isinstance()

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Changed to base in (0, 1)

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Updated to div not in (0, 1)

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Updated to make condition clearer

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Using divmod() instead of % operator

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Improved readability on a docstring test

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Changed use of type() to isinstance()

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update conversions/decimal_to_any.py

Changed from use of type() to isinstance()

Co-authored-by: Christian Clauss <cclauss@me.com>

* Made changes and improved function

* Update conversions/decimal_to_any.py

Added space to docstring test

Co-authored-by: Christian Clauss <cclauss@me.com>

* Changed action for bad input

* Added support for conversions up to base 36 (#2087)

* Added support for conversions up to base 36 and renamed HEXADECIMAL dict (#2087)

* Fixed whitespace issue (#2087)

* Fixed issue with line length (#2087)

* Fixed issue with conversions past base-10 failing (#2087)

* Added more robust testing (#2087)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-11 17:59:42 +02:00
ocivo
a7b4311378
fix fetch_github_info __main__ bug (#2080)
* fix fetch_github_info __main__ bug

* Algorithms should not print

* Update fetch_github_info.py

* Update fetch_github_info.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-06-11 16:38:43 +02:00
Christian Clauss
657d46101d
calc_profit always returns an int (#2090)
* calc_profit always returns an int

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-11 16:36:09 +02:00
mateuszz0000
3de6f010c3
Refactor remove duplicates to more pythonic (#2093)
* Refactor strings/remove_duplicate to more pythonic

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-11 06:13:40 +02:00
Jeffin Francis
bf0da25e4f
Added Readme for computer vision (#2075)
* Create README.md

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-10 17:10:47 +02:00
mateuszz0000
e553f4bf11
Added travis notifications only on fail (#2091)
* Added travis notifications only on fail

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-10 12:40:52 +02:00
Apoorve
7be3d0f667
Create-Add files to greedy_method directory (#2082)
* Add Greedy Method Approach

* Update Filename

* Update Variable and Links

* Fixed flake8 bugs

* Update unittest filename

* Update unittest filename

* Final unittest filename update

* Pythonic Code formatting

* flake8 fixes

* lowercase function name

* Add zip function

* Add zip function

* params lowercase

* Travis CI fixes

* Update and rename knapsack_problem.py to knapsack.py

* Update test_knapsack.py

* Fix bugs

* Rename knapsack.py to greedy_knapsack.py

* Update test_knapsack.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-09 17:59:19 +02:00
mateuszz0000
1e7df7f77a
Errors notifications under pull requests (#2081)
* Added error comments under pull requests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-08 14:11:01 +02:00
mateuszz0000
6752e9c737
Remove boilerplate comments and unused variables (#2073) 2020-06-07 23:05:22 +02:00
mateuszz0000
20b21e5ec9
Refactor cycle_sort (#2072)
* Refactor cycle_sort

* Undo changes to keep only doctests
2020-06-05 09:13:43 +02:00
Jeffin Francis
7a14285cb6
Harris corner detection (#2064)
* Added Lstm example for stock predection

* Changes after review

* changes after build failed

* Add Kiera’s to requirements.txt

* requirements.txt: Add keras and tensorflow

* psf/black

* haris corner detection

* fixup! Format Python code with psf/black push

* changes after review

* changes after review

* fixup! Format Python code with psf/black push

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-04 16:02:51 +02:00
Vignesh
0904610a76
create sum_of_digits.py (#2065)
* create sum_of_digits.py

create sum_of_digits.py to find the sum of digits of a number
digit_sum(12345) ---> 15
digit_sum(12345) ---> 10

* Update sum_of_digits.py

* Update maths/sum_of_digits.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update maths/sum_of_digits.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update sum_of_digits.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-02 23:38:32 +02:00
Martin Röbke
35319a2a2a
Update build_directory_md.py (#2066)
Propagate argument `top_dir` to good_file_paths.
Previously this argument did not get passed to the helper function when calling print_directory_md.
2020-06-02 21:14:12 +02:00
Shivam Verma
d7cc778092
conversions/decimal_to_binary.py: Add type hints (#2001)
* A .py file to covert a base to any new base(2-18)

* Update base_changer.py

* Added type-hints.

* Delete base_changer.py
2020-06-02 16:47:10 +02:00
mateuszz0000
b080a5e027
Doctests + typehints in cocktail shaker sort (#2061)
* Doctests in cocktail shaker sort

* import doctest

* print(f"{cocktail_shaker_sort(unsorted) = }")

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-02 11:51:22 +02:00
Vignesh
dc720a83d7
Create number_of_digits.py (#1975)
* Create number_of_digits.py

A python program to find the number of digits in a number.

* Update number_of_digits.py

* Update number_of_digits.py

* Add #1976 to get Travis CI to pass

#1976

* Add type hints as discussed in CONTRIBUTING.md

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-01 17:23:15 +02:00
mateuszz0000
1a254465e3
Naive string doctests + typehints (#2054)
* Added doctests

* Added __main__

* Commit suggestion

* Undo changes to keep only doctests and typehints

* Reundo function name with params

* Update naive_string_search.py

* Update naive_string_search.py

* Update naive_string_search.py

* Update naive_string_search.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-01 15:40:40 +02:00
Lakshmikanth2001
321b1425e3
data_structures/linked_list: Add __len__() function and tests (#2047)
* Update __init__.py

please add a function to get length of linked list

* Update __init__.py

* Update doubly_linked_list.py

all size function lo doubly linked list class

* prime number _better method

* comments

* Updated init.py 2

made it more pythonic

* updated length function

* commnet in linked_list construtor

* Update data_structures/linked_list/__init__.py

accepecting changes

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/linked_list/__init__.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update __init__.py

* Revert changes to doubly_linked_list.py

* Revert changes to prime_check.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-31 11:37:45 +02:00
Christian Clauss
1e8fe8efcf
circular_linked_list: Add more len() tests (#2051)
* circular_linked_list: Add more len() tests

* fixup! Format Python code with psf/black push

* prepend()

* updating DIRECTORY.md

* Fix decrementation of self.length

* Add empty list tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-31 13:06:57 +05:30
mateuszz0000
3357768fc3
Jaro winkler (#2041)
* Added jaro_winkler first version

* Added doctests

* Fix flake warnings

* Refactor

* Fixes bug in jaro winkler implementation

* Commit suggestions

* Missing comming suggestions

* Remove unused math module

* Import doctest

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-05-31 00:14:55 +05:30
Christian Clauss
fa358d614a
current_weather, weather_forecast, weather_onecall (#2048)
* current_weather, weather_forecast, weather_onecall

* updating DIRECTORY.md

* weather_forecast("Kolkata, India")

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-30 23:47:26 +05:30
Swapnanil Dutta
f8bfd0244d
Created weatherforecast.py (#2037)
* Created weatherforecast.py

Added weatherforecast.py to retrieve weather information of a location and return dictionary values.

* Update weatherforecast.py

* Update and rename weatherforecast.py to current_weather.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-30 17:25:06 +02:00
KDH
4768735668
Enhance shell sort syntax (#2035) 2020-05-26 04:18:03 +02:00
Nitisha Bharathi
0e619065e7
added Boruvka's MST algorithm (#2026)
* added Boruvka's MST algorithm

* Add files via upload

* fixup! Format Python code with psf/black push

* Updated Boruvka with doctest

* updating DIRECTORY.md

* Update minimum_spanning_tree_boruvka.py

* No blank line in doctest

* <BLANKLINE>

* Avoid mutable default values

https://docs.python-guide.org/writing/gotchas/

* Update minimum_spanning_tree_boruvka.py

* Avoid mutable default values

* fixup! Format Python code with psf/black push

* Update minimum_spanning_tree_boruvka.py

* Update minimum_spanning_tree_boruvka.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-25 15:10:54 +02:00
mateuszz0000
bb5552efd0
Euclidean recursive method + doctests + type hints (#1999)
* Recursive euclidean algorithm + doctests and type hints

* Fix doctests in recursive method

* Added commit suggestions
2020-05-25 12:32:57 +02:00
Christian Clauss
dc4049ee28
.travis.yml: Revert to using autoblack (#2033)
* .travis.yml: Revert to using autoblack

Our autoblack GitHub Action will get us to black compliance without forcing each contributor to learn about, install, and use psf/black on every pull request.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-24 20:38:28 +05:30
Ekansh Mangal
025b1a6989
Merge sort Update variable names (#2032)
* Update Merge sort variable names

* Update mergesort.py

* Update mergesort.py

* black

* Update mergesort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-24 08:38:43 +02:00
Ashwin Das
d8a4faf96d
Update is_palindrome.py (#2025)
* Update is_palindrome.py

* Update is_palindrome.py

* Reuse s

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-22 11:57:23 +02:00
mateuszz0000
a15f82579d
Added bead sort (#2022)
* Added bead sort

* Commit suggestion

* Added checking before sort

* Bead sort only works for sequences of nonegative integers

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-22 09:41:40 +02:00
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Erwin Lejeune
21ed8968c0
Fixes in Bidirectional A* (#2020)
* implement bidirectional astar

* add type hints

* add wikipedia url

* format with black

* changes from review

* fix collision check

* Add testmod()

* # doctest: +NORMALIZE_WHITESPACE

* Codespell: euclidean

* Codespell: coordinates

* Codespell: traversal

* Codespell: remaining

Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-21 21:50:52 +02:00
Erwin Lejeune
dc596d23a9
Graphs : Greedy Best First (#2018)
* implement greedy best first

* implement Greedy Best First Search

* review changes

* add doctests

* >>> gbf.search()  # doctest: +NORMALIZE_WHITESPACE

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-20 23:25:48 +02:00
Erwin Lejeune
1f2d607e56
Graphs : Bidirectional A* (#2015)
* implement bidirectional astar

* add type hints

* add wikipedia url

* format with black

* changes from review
2020-05-20 12:20:22 +05:30
mateuszz0000
965d02ad41
Update atbash cipher (doc, doctest, performance) (#2017)
* Update atbash

* Add benchmark() to quantify the performance improvement

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-20 08:23:17 +02:00
Sanders Lin
777ddca2e9
Update fast_fibonacci.py (#1889)
* Update fast_fibonacci.py

* Update fast_fibonacci.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-19 19:31:52 +02:00
Christian Clauss
0e6e5056b3
singly_linked_list.py: psf/black (#2008)
* singly_linked_list.py: psf/black

* updating DIRECTORY.md

* Update singly_linked_list.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 13:54:25 +02:00
mateuszz0000
2431001658
Easter date gauss algorithm (#2010)
* Added gauss easter algorithm

* Fixes in easter algorithm

* Commit suggestions
2020-05-19 13:44:45 +02:00
Jie Han
c906ba82f3
refactor: move import pytest line of blockchain algs under "main" section. (#2012)
* change doctest line

import doctest is not relevant with algorithms. move it under main section.

* from doctest import testmod

* refactor: move doctest under "main" section

* Update diophantine_equation.py

* Update modular_division.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-19 12:56:16 +02:00
Christian Clauss
1c62bd10c1
Precision must be a nonnegative integer (#2013)
* Precision must be a nonnegative integer

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-19 15:46:20 +05:30
Adityanagraj
e6fdcc90fd
consists of area of various geometrical shapes (#2002)
* consists of area of various geometrical shapes

In this program it consists of various area calculation of different geometrical shapes such as (square,rectangle) and many other shapes.

* print(f'Rectangle: {area_rectangle(10, 20)=}')

* Update area.py

* Areas of various geometric shapes:

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 23:06:19 +02:00
Kenneth P
77f3888b71
Pi digit extraction algorithm (#1996)
* added pi digit extraction formula

* updating DIRECTORY.md

* fixed typo in a comment

* updated bbp_formula.py

* Update maths/bbp_formula.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update maths/bbp_formula.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update bbp_formula.py

* Update and rename bbp_formula.py to bailey_borwein_plouffe.py

* updating DIRECTORY.md

* calculate

* "".join(bailey_borwein_plouffe(i) for i in range(1, 12))

* Update bailey_borwein_plouffe.py

* Update bailey_borwein_plouffe.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 22:54:08 +02:00
Jie Han
7a8696cd6d
change doctest line (#2007)
* change doctest line

import doctest is not relevant with algorithms. move it under main section.

* from doctest import testmod

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 21:44:27 +02:00
Akash
f9e0dd94d6
added __len__ function (#1812)
* added __len__ function

Added a function to count number of nodes in linked list

* Updated __len__ method

used snake_case instead of camel case

* Add tests to __len__()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-18 18:10:55 +02:00
Christian Clauss
38d2e98665
hill_cipher.py: gcd() -> greatest_common_divisor() (#1997)
* hill_cipher.py: gcd() -> greatest_common_divisor()

* fixup! Format Python code with psf/black push

* import string

* updating DIRECTORY.md

* Change matrix to array

Add more tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-05-18 13:05:51 +02:00
Bharath kumar Reddy Kotha
aa120cea12
Add tests and type hints to hill cipher (#1991)
* Added tests and type hints to hill cipher

* Remove extra >>>

* import doctest

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-05-18 09:03:20 +02:00
mateuszz0000
bc8e8f03fd
Added strand sort (#1982)
* Added strand sort

* Review changes

* Remove boilerplate code

* Fixed flake error: E252

* Added missing return type hint
2020-05-17 22:48:39 +02:00
Christian Clauss
565060aa99
actions/setup-python@v2 (#1986)
* actions/setup-python@v2

* fixup! Format Python code with psf/black push

* Update autoblack.yml

* updating DIRECTORY.md

* Update codespell.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-16 08:49:56 +02:00
Kenneth P
a29a2a3a06
Added file aliquot_sum.py (#1985)
* Added file aliquot_sum.py containing a function to find theo

* Added parameter type info to aliquot_sum.py

* Update maths/aliquot_sum.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update maths/aliquot_sum.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Updated code to raise ValueErrors if input is bad

* Fixed logical operators

* Removed unnecessary import

* Updated aliquot_sum.py

* fixed formatting

* fixed documentation

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-05-15 08:06:51 +02:00