Commit Graph

1810 Commits

Author SHA1 Message Date
Christian Clauss
2c98dce057
Rename shortest_job_first_algorithm.py to shortest_job_first.py (#2164)
* Rename shortest_job_first_algorithm.py to shortest_job_first.py

* updating DIRECTORY.md

* Minor tweek to round_robin.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-04 00:56:40 +05:30
Pawan Sundargiri
e274863cda
Add round_robin scheduling algorithm (#2158)
* round_robin and priority cpu scheduling algorithms

* Delete priority_cpu_scheduling.py

* Delete round_robin_algorithm.py

* [add] cpu_scheduling_algorithms

* [add] Round robin cpu scheduling algorithm

* Update scheduling/round_robin_scheduling_algorithm.py

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

* Update scheduling/round_robin.py

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

* Update scheduling/round_robin_scheduling.py

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

* Update scheduling/round_robin_scheduling.py

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

* Update scheduling/round_robin.py

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

* Round_Robin

* Update round_robin.py

* Update round_robin.py

* Update round_robin.py

* Update round_robin.py

Co-authored-by: pawanbuddy <46370996+pawanbuddy@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-07-03 15:11:07 +02:00
vinayak
2d3d660155
black fixes and Travis CI fixes (#2160)
* black format

* updating DIRECTORY.md

* fixes

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-02 20:02:15 +05:30
Tapajyoti Bose
c534e77cb1
Added minimum cost path algorithm (#2135)
* Added maximum path sum for matrix (top left to bottom right)

* Changed maximum cost path to minimum cost path + added video explaination
2020-07-02 14:43:29 +05:30
Christian Clauss
8ab84fd794
Only one carriage return (#2155)
* updating DIRECTORY.md

* touch

* fixup! Format Python code with psf/black push

* Update word_frequency_functions.py

* updating DIRECTORY.md

* Update word_frequency_functions.py

* Update lfu_cache.py

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-25 19:15:30 +02:00
wuyudi
d2fa91b18e
Add url and typing hint for BFS (#2156)
* Add typing for bfs

* Add url for BFS

* rename the function

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

* Update graphs/bfs.py

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

* Change the return value type of bfs

* change the function name.

change all instances of bfs() to breadth_first_search().

* change the function name in annotate

* Add one more blank line.

* Delete one blank line.

* Delete one blank line.

I've read the https://www.flake8rules.com/rules/W391.html, and still don't know how to do it. I've tried using 0 ,1,2 blank lines...

* Update graphs/bfs.py

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

* Update graphs/bfs.py

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

* Rename bfs.py to breadth_first_search_2.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 17:54:41 +02:00
Mark Moretto
3d4172307f
project_euler/problem_47/sol1.py (#2150)
* Create __init__.py

* Initial commit

Not sure if this should be formatted differently.  I'm open to ideas!

* Completing testing/updates

Ran code through `black`, `flake8`, and `doctest`.  Added some type hints.

`doctest` is finicky on sets, so I had to sort and reformat as set to pass those tests.

* Update project_euler/problem_47/sol1.py

Nice.

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

* Update project_euler/problem_47/sol1.py

Looks good

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

* Update project_euler/problem_47/sol1.py

Okay, this should work.  Thank you for the reminder on map(), filter(), reduce().

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

* Update project_euler/problem_47/sol1.py

My IDE needs a spellchecker.  Or, lighter comment font.

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

* Update project_euler/problem_47/sol1.py

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

* Update project_euler/problem_47/sol1.py

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

* Update project_euler/problem_47/sol1.py

This means that `results = run(N)` should be updated to `results = run(n)`, correct?

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

* Update project_euler/problem_47/sol1.py

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

* Update project_euler/problem_47/sol1.py

Looks good!

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

* Update project_euler/problem_47/sol1.py

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

* Update project_euler/problem_47/sol1.py

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

* Update project_euler/problem_47/sol1.py

Works for me! I spent way too much time getting this to pass doctest, so any improvement is welcome.

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

* Update sol1.py

Added some suggested changes from the pull request:
* Updated tests outputs in `unique_prime_factors` function.
* Changed `@lru_cache(maxsize=5)` to `@lru_cache(maxsize=None)`
* Removed duplicate `return` line in `equality` function
* Changed `i` to `base` in run function.
* Added some commentary to `run()` function.
* Replaced `group = list(map(lambda x: base + x, [i for i in range(n)]))` with `group = [base + i for i in range(n)]`

* Update sol1.py

* Trailing whitespace

* Update sol1.py

* Update __init__.py

* Update sol1.py

* Update __init__.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 12:25:19 +02:00
Tapajyoti Bose
9eb3138b81
Added LFU Cache (#2151)
* Added LFU Cache

* Update lfu_cache.py

* None is returned

* Add type hints

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 11:40:50 +02:00
Tapajyoti Bose
27dde06dfa
Added LRU Cache (#2138)
* Added LRU Cache

* Optimized the program

* Added Cache as Decorator + Implemented suggestions

* Implemented suggestions
2020-06-25 11:40:03 +02:00
Dan Murphy
b368b1ecfd
NLP Word Frequency Algorithms (#2142)
* NLP Word Frequency Algorithms

* Added type hints and Wikipedia link to tf-idf

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Fix line length for flake8

* Fix line length for flake8 V2

* Add line escapes and change int to float

* Corrected doctests

* Fix for TravisCI

* Fix for TravisCI V2

* Tests passing locally

* Tests passing locally

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Update machine_learning/word_frequency_functions.py

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

* Add doctest examples and clean up docstrings

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 10:00:43 +02:00
Markgolzh
c7ca9cf0df
Update avl_tree.py (#2145)
* Update avl_tree.py

it's true definition of AVL tree,change  left and right rotation,and add avl_tree doctest

* Update avl_tree.py

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update data_structures/binary_tree/avl_tree.py

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

* Update avl_tree.py

update some function name and update doctest

* Update avl_tree.py

change some code format to fit flake8 review

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-25 09:55:13 +02:00
mateuszz0000
b0c3c0fbf6
Typehints + refactor (#2154) 2020-06-25 09:48:52 +02:00
mateuszz0000
9e2206e5fb
Added doctests to OddEvenTraposition (#2152)
* Added doctests

* Change __main__ content
2020-06-25 08:56:57 +02:00
Christian Clauss
5b6ebf8f12
Add doctests to radix_sort() (#2148)
* Add doctests to radix_sort()

* fixup! Format Python code with psf/black push

* Update radix_sort.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-23 15:37:24 +02:00
Tapajyoti Bose
f1ce2d6e80
Added Markov Chain (#2146)
* Added Markov Chain

* Implemented suggestions
2020-06-23 12:56:08 +02:00
Christian Clauss
cbbaa98684
hamming_code.py: Reduce McCabe code complexity (#2140)
* hamming_code.py: Reduce McCabe code complexity

As discussed in #2128

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-22 14:18:57 +02:00
Christian Clauss
fdc5bee7af
Euler problem 551 sol 1: Reduce McCabe code complexity (#2141)
* Euler problem 551 sol 1: Reduce McCabe code complexity

As discussed in #2128

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-22 14:16:12 +02:00
beqakd
d034add61f
add visualization of k means clustering as excel format (#2104)
* add visualization of kmneas clust as excel format

* style changes

* style changes

* Add doctest and typehint!

* style change

* Update machine_learning/k_means_clust.py

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

* Update machine_learning/k_means_clust.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-19 17:55:13 +02:00
Tapajyoti Bose
b9e7c891e2
Added (Open) Knight Tour Algorithm (#2132)
* Added (Open) Knight Tour Algorithm

* Implemented Suggestions
2020-06-18 11:30:24 +02:00
Ioane Margiani
19b713aecb
Add lempel ziv compression (#2107)
* Added lempel-ziv compression algorithm implementation

* Added lempel-ziv decompression algorithm implementation

* Reformatted lempel-ziv compress/decompress files using black

* Added type hints and some other modifications (Doctests coming up)

* Shortened several lines to comply with the standards
2020-06-17 21:12:48 +02:00
Nika Losaberidze
671e570c35
Implement prefix function, knuth-morris-pratt another usage (#2099)
* Implement prefix function, knuth-morris-pratt another usage

* fixup! Format Python code with psf/black push

* Fix style

* updating DIRECTORY.md

* Update prefix_function.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-17 18:27:05 +02:00
Nika Losaberidze
fb3a228d26
Strongly connected components (#2114)
* Implement strongly connected components for graph algorithms

* fixup! Format Python code with psf/black push

* Delete trailing whitespace

* updating DIRECTORY.md

* Add doctests and typehints

* Remove unnecessary comments, change variable names

* fixup! Format Python code with psf/black push

* Change undefined variable's name

* Apply suggestions from code review

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

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-17 18:16:54 +02:00
Nika Losaberidze
2bbdc3bfe7
Implement connected components algorithm for graphs (#2113)
* Implement connected components algorithm for graphs

* fixup! Format Python code with psf/black push

* Add parameters and return values annotations with Python type hints

* updating DIRECTORY.md

* Add doctests and typehints

* Remove unnecessary comments, change variable names

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-17 18:15:24 +02:00
Tapajyoti Bose
23484efdad
Added maximum non-adjacent sum (#2130)
* Added maximum non-adjacent sum

* Bugfix: flake8 test

* Implemented changes (broke tuple unpacking into 2 lines due to flake8 tests)

* Implemented changes v2.0

* Update max_non_adjacent_sum.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-17 17:09:29 +02:00
mateuszz0000
d7a75da8ef
Added doctests to bucket sort (#2079)
* Added doctests to bucket sort

* Missing typehint

* Wrap long lines

* updating DIRECTORY.md

* Update bucket_sort.py

* updating DIRECTORY.md

* Update bucket_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-17 09:42:44 +02:00
Furkan Atesli
6f80ca821c
Create change_brightness.py (#2126)
* Create change_brightness.py

* Update change_brightness.py

* Update change_brightness.py

* Update change_brightness.py

* Update change_brightness.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-17 07:49:20 +02:00
Christian Clauss
f97af65579
Blacken our code (#2125)
* Blacken

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-17 06:59:38 +08:00
bnMikheili
62f7561428
Hash djb2 (#2098)
* implement hash

* fix flake8 error

* Update hashes/djb2.py

* Update hashes/djb2.py

* Long lines

* def djb2(s: str) -> int:

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-16 22:22:47 +02:00
beqakd
924ef9b7d8
implementation of entropy algorithm. (#2110)
* implementation of entropy algorithm.

* add tests, fix requested changes

* open_file() --> analyze_text()

* Create bidirectional_breadth_first_search.py

* # type: ignore

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-16 21:36:57 +02:00
Erwin Lejeune
a5c246793c
Graphs : Bidirectional Breadth-First Search (#2057)
* implement bidirectional breadth first

* remove useless import

* remove trailing whitespaces
2020-06-16 17:10:22 +02:00
Christian Clauss
4e8a0d924e
CONTRIBUTING.md: Update flake8 command (#2124)
* CONTRIBUTING.md: Update flake8 command

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 16:33:17 +02:00
Muhammadrasul
4a2d457747
Count (#2084)
* Add files via upload

* Update and rename count_islands.py to count_islands_in_matrix.py

* Update matrix/count_islands_in_matrix.py

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

* Update matrix/count_islands_in_matrix.py

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

* Update matrix/count_islands_in_matrix.py

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

* Reformat count islands.py

* Indent Python code with 4 spaces, not tabs

* Update count_islands_in_matrix.py

* Add type hints for return values

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-16 14:36:09 +02:00
Christian Clauss
b9e5259aeb
Fix long line, tests (#2123)
* Fix long line

* updating DIRECTORY.md

* Add doctest

* ...

* ...

* Update tabu_search.py

* space

* Fix doctest

    >>> find_neighborhood(['a','c','b','d','e','a'])  # doctest: +NORMALIZE_WHITESPACE
    [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90],
     ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102],
     ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]]

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-06-16 14:29:13 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
Michael Quevillon
9438c6bf0b
Add pytest init file to define custom mark mat_ops (#2120)
Fixes #1917.
2020-06-15 18:09:32 +02:00
Christian Clauss
0b028aa32a
Fix line break after binary operator (#2119)
* Fix line break after binary operator

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-15 15:47:02 +02:00
beqakd
23dae9ceab
implement rat in maze algorithm. (#2106)
* implement rat in maze algorithm.

* style changes

* fix trailing whitespace

* add test, fix style

* fix style

* method change

* minor changes

* style changes

* return solved

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-15 15:03:30 +02:00
Christian Clauss
b9185bebd6
Create natural_language_processing (#2116)
* Create natural_language_processing

Closes #2115

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-15 09:55:41 +02:00
bnMikheili
55b3088e47
Hash adler32 (#2111)
* implement hash

* fix indentation
2020-06-14 09:49:39 +02:00
Christian Clauss
ae9d0f9196
Fix indentation (#2097) 2020-06-14 14:28:00 +08:00
Nika Losaberidze
8bb7b8f457
Fix syntax for flake8 passing (#2096)
* Fix syntax for flake8 passing

* fixup! Format Python code with psf/black push

* # fmt: off / # fmt: on

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-06-12 06:51:47 +02:00
bnMikheili
ec2d900b03
implement sdbm hash algorithm (#2094)
* implement sdbm hash algorithm

* fix bug: styling

* fix styling for decimal_to_any
2020-06-11 22:22:16 +02:00
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