Commit Graph

1800 Commits

Author SHA1 Message Date
Björn Olsson Jarl
8c191f1fc9
Added type hints for maths/fibonacci_sequence_recursion. (#2372) 2020-08-30 10:51:45 +02:00
Björn Olsson Jarl
ab5a046581
Added type hints and doctest for maths/prime_check. (#2367)
* Added type hints and doctest for maths/prime_check.

* Removed doctests.
2020-08-29 17:11:02 +02:00
Kushagra Bansal
f2f0425357
Created ugly_numbers.py in Python/maths (#2366)
* Add files via upload

* Update ugly_numbers.py

* Update ugly_numbers.py

* Update ugly_numbers.py
2020-08-29 16:57:34 +02:00
Aanuoluwapo Babajide
1f5134b368
Create alternate_disjoint_set.py (#2302)
* Create alternate_disjoint_set.py

This code implements a disjoint set using Lists 
with added heuristics for efficiency
Union by Rank Heuristic and Path Compression

* Update alternate_disjoint_set.py

Added typehints, doctests and some suggested variable name change

* Update alternate_disjoint_set.py

* Formatted with Black

* More formatting

* Formatting on line 28

* Error in Doctest

* Doctest Update in alternate disjoint set

* Fixed build error

* Fixed doctest
2020-08-28 18:25:02 +02:00
Kushagra Bansal
5ef784331e
Created triplet_sum in Python/other (#2362)
* Add files via upload

* Update triplet_sum.py

* Update triplet_sum.py

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update triplet_sum.py

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

* Update other/triplet_sum.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-28 15:50:35 +02:00
Kushagra Bansal
194b56d376
Created problem_63 in project_euler (#2357)
* Create __init__.py

* Add files via upload

* Update project_euler/problem_63/sol1.py

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

* Update sol1.py

* Update sol1.py

* Update sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-27 13:40:03 +02:00
wuyudi
cf385ad7ef
Update merge_sort.py (#2356)
* Update merge_sort.py

* Update merge_sort.py
2020-08-27 09:45:03 +02:00
Firejay3
61dde44434
Added binery_or_operator.py to bit manipulation file (#2331)
* added bitwise binary OR operator

* Rename binary_OR_operator.py to binary_or_operator.py

* Update binary_or_operator.py

* Update binary_or_operator.py

* Update bit_manipulation/binary_or_operator.py

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

* Update binary_or_operator.py

* Update binary_or_operator.py

* Nice!!

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-27 09:09:42 +02:00
TrapinchO
30126c26dd
Added enigma machine emulator (#2345)
* Added Enigma machine file

Added Enigma machine file to 'ciphers' section

* Added doctest to validator

* Fixed typo

* Shortened some lines

* Shortened some lines

* Update enigma_machine.py

* Shortened some lines

* Update enigma_machine.py

* Update enigma_machine.py

* Update enigma_machine2.py

* Update enigma_machine2.py

* added f-strings

* Update enigma_machine2.py

* Update enigma_machine2.py

* Updated some numbers

* Plugboard improvement

Added option to separate pair for plugboard by spaces

* renamed variable

* renamed some variables

* improved plugboard exception

* Update enigma_machine2.py

* Update enigma_machine2.py
2020-08-26 21:52:17 +02:00
Kushagra Bansal
9aa10ca358
Created problem_55 in project_euler (#2354)
* Create __init__.py

* Add files via upload

* Update sol1.py
2020-08-26 13:31:13 +02:00
Iheb Haboubi
2c0127d71a
Perfect square using binary search (#2351)
* Add perfect_square_binary_search

* Update tests

* Add tests
2020-08-25 21:26:11 +02:00
Christian Clauss
ee914c751c
Delete sleep_sort.py (#2352)
* Delete sleep_sort.py

A silly algorithm designed to waste time.  #2350 demonstrates that it is a 20+ second denial of service attack on every Travis CI run that we do.

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-25 15:48:04 +02:00
Christian Clauss
e77600638d
Travis CI: Identify our ten slowest pytests (#2350)
* Travis CI: Identify our ten slowest tests

https://howchoo.com/g/mtblodnjzjc/how-to-measure-unit-test-execution-times-in-pytest helps us to find the individual tests that are slowing down our Travis CI checks.

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-25 15:47:06 +02:00
Kushagra Bansal
402ba7f49a
Created problem_45 in project_euler and Speed Boost for problem_34/sol1.py (#2349)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_45/sol1.py

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

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_34/sol1.py

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

* Update project_euler/problem_34/sol1.py

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

* Update sol1.py

* Update project_euler/problem_34/sol1.py

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

* Update sol1.py

* Update project_euler/problem_34/sol1.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-25 13:48:19 +02:00
Kushagra Bansal
5cfc017ebb
Created problem_44 in project_euler (#2348)
* Create __int__.py

* Update and rename project_euler/__int__.py to project_euler/problem_44/__int__.py

* Add files via upload

* Update sol1.py

* Update __int__.py

* Delete __int__.py

* Create __init__.py

* Update project_euler/problem_44/sol1.py

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

* Update project_euler/problem_44/sol1.py

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

* Update project_euler/problem_44/sol1.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-25 09:46:13 +02:00
kanthuc
f8c57130f2
lazy_segment_tree.py-style-fixes (#2347)
* fixed variable naming and unnecessary type hints

* print(segt)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-24 09:52:02 +02:00
BAKEZQ
d402cd0b6e
Fix SettingWithCopy warning by pandas (#2346)
* Fix SettingWithCopy warning in pandas

https://github.com/TheAlgorithms/Python/issues/2282

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py

* Update k_means_clust.py
2020-08-23 13:40:57 +02:00
Guillaume Rochedix
ee28deea4a
Insertion sort : type hint, docstring (#2327)
* insertion sort : docstring, type hinting

* Update insertion_sort.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-23 04:35:54 +02:00
Kaif Kohari
a46b5559e0
Job fetching (#2219)
* Adding job scarping algorithm to web programming

* Delete fetch_jobs.py

* Adding Jobs Scraping to web programming

* Add Python type hints

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-21 23:58:26 +02:00
wuyudi
6822d1afeb
Update matrix_operation.py (#2344)
* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py

* Update matrix_operation.py
2020-08-21 20:41:48 +02:00
Kushagra Bansal
ae33419c12
Created problem_46 in project_euler (#2343)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_46/sol1.py

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

* Update project_euler/problem_46/sol1.py

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

* Update sol1.py

* exact

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-21 14:09:55 +02:00
SiddhantBobde
0bf1f22d37
Added function for finding K-th smallest element in BST (#2318)
* fixes: #2172

* fixes: #2172

* Added docstrings and type of parameters

* fixed error

* Added type hints

* made changes

* removed capital letters from function name

* Added type hints

* fixed bulid error

* modified comments

* fixed build error
2020-08-21 12:25:50 +05:30
Du Yuanchao
0591968947
Optimization and fix bug (#2342)
* * optimization aliquot_sum
* fix bug in average_median

* fixup! Format Python code with psf/black push

* Update maths/average_median.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-21 14:39:03 +08:00
kanthuc
2eaacee7b4
lowest_common_ancestor.py static type checking (#2329)
* adding static type checking to basic_binary_tree.py

* Add static type checking to functions with None return type

* Applying code review comments

* Added missing import statement

* fix spaciing

* "cleaned up depth_of_tree"

* Add doctests and then streamline display() and is_full_binary_tree()

* added static typing to lazy_segment_tree.py

* added missing import statement

* modified variable names for left and right elements

* added static typing to lowest_common_ancestor.py

* fixed formatting

* modified files to meet style guidelines, edited docstrings and added some doctests

* added and fixed doctests in lazy_segment_tree.py

* fixed errors in doctests

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-21 06:54:34 +02:00
Alex Joslin
d3199da000
Created Dijkstra's Two Stack Algorithm (#2321)
* created dijkstra's two stack algorithm

* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.

* Made changes to dijkstras two stack algorithm for documentation and
testing purposes.

* Fixed Grammar Mistake

* Added Explanation Reference

* Imported stack instead of using my own
Changed a few minor things.

* Imported stack instead of using my own
Changed a few minor things.

* Update data_structures/stacks/dijkstras_two_stack_algorithm.py

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

* Update dijkstras_two_stack_algorithm.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-20 17:49:43 +02:00
Kushagra Bansal
456893cb5f
Created problem_43 in project_euler (#2340)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Lose a list()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-20 17:02:14 +02:00
Christian Clauss
8817a3e667
Delete natural_language_processing (#2317)
* Delete natural_language_processing

This file is useless.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-19 21:53:56 +02:00
Kushagra Bansal
2eca71663b
Created check_anagrams.py in strings (#2339)
* Add files via upload

* Update check_anagrams.py

* Update check_anagrams.py

* Update check_anagrams.py

* Update check_anagrams.py

* “” or not

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-19 18:24:02 +02:00
Kushagra Bansal
9351889fda
Created problem_41 in project_euler (#2334)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update sol1.py
2020-08-19 12:55:06 +02:00
Kushagra Bansal
9a32f0b46c
Created problem_39 in project_euler (#2330)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_39/sol1.py

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

* Update sol1.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-18 12:49:02 +02:00
Kushagra Bansal
051be078e4
Fix typo (#2325) 2020-08-17 17:43:46 +02:00
Kushagra Bansal
88341d1727
Created problem_37 in project_euler (#2323)
* Create __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_37/sol1.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-17 16:39:58 +02:00
Du Yuanchao
34294b5641
Update sum_of_digits.py (#2319)
* * support negative number
* add different version

* fixup! Format Python code with psf/black push

* sum(int(c) for c in str(abs(n)))

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-16 20:31:06 +02:00
Kushagra Bansal
7e4176ccaf
Created problem_35 in project_euler (#2309)
* Create __init__.py

* Update __init__.py

* Add files via upload

* Update sol1.py

* Update sol1.py to include type hints

* Update CONTRIBUTING.md to fix typo

* Update CONTRIBUTING.md

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update project_euler/problem_35/sol1.py

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

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Fix the print(f"string")

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-16 07:52:48 +02:00
Yukti Khosla
14199e0590
Create Transformations2D.py (#2310)
* Create Transformations2D.py

* Update Transformations2D.py

* Drop numpy and add type hints and doctests

* Rename Transformations2D.py to transformations_2d.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-15 18:19:33 +02:00
Guillaume Rochedix
fcc8a28c31
Gnome sort : type hints, docstrings, doctests (#2307)
* gnome_sort : type hints, docstring, doctests

* !Gadeimnoprstu

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-14 22:00:08 +02:00
Kushagra Bansal
b3ae39249d
Created problem_34 in project_euler (#2305)
* Create __init__.py

* Add files via upload

* Rename solution.py.py to solution.py

* Delete __init__.py

* Update and rename solution.py to sol1.py

* Update sol1.py

* Create __init__.py

* Update __init__.py

* Delete __init__.py

* Add files via upload

* Update __init__.py

* Add #\n

* Update sol1.py

Incorporates the proposed changes

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_34/sol1.py

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

* Update project_euler/problem_34/sol1.py

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

* Update project_euler/problem_34/sol1.py

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

* Update project_euler/problem_34/sol1.py

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

* Update sol1.py

* Update sol1.py

* Update sol1.py

* Use int(n) instead of floor(n)

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-13 16:52:47 +02:00
Du Yuanchao
d687030d9e
fix number_of_digits bug (#2301)
* fix bug

* test larger negative

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-12 18:32:35 +02:00
Tapajyoti Bose
aa46639cbc
Added Kruskal's Algorithm (more organized than the one present) (#2218)
* Added Kruskal's Algorithm

* Added Type Hints

* fixup! Format Python code with psf/black push

* Added Type Hints V2

* Implemented suggestions + uniform naming convention

* removed redundant variable (self.nodes)

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-12 12:16:17 +02:00
kanthuc
d25a926c02
adding static type checking to basic_binary_tree.py (#2293)
* adding static type checking to basic_binary_tree.py

* Add static type checking to functions with None return type

* Applying code review comments

* Added missing import statement

* fix spaciing

* "cleaned up depth_of_tree"

* Add doctests and then streamline display() and is_full_binary_tree()

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-11 23:38:38 +02:00
Christian Clauss
e49ece95a4
PIL.Image.point() takes an int, not a float (#2284)
* PIL.Image.point() takes an int, not a float

@furkanatesli Trying to remove these warnings from our Travis CI build logs...
https://travis-ci.com/github/TheAlgorithms/Python/builds/178602503#L809

* fixup! Format Python code with psf/black push

* Revert changes to change_brightness.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-07 21:20:56 +02:00
Christian Clauss
1fb1fdd130
requirements.txt: Unpin numpy (#2287)
* requirements.txt: Unpin numpy

* fixup! Format Python code with psf/black push

* Less clutter

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-06 17:50:23 +02:00
Sanders Lin
f0d7879a11
fixed error in factorial.py (#1888)
* Update factorial.py

* updating DIRECTORY.md

* Update dynamic_programming/factorial.py

* Update factorial.py

Co-authored-by: mateuszz0000 <mtszzwdzk@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-05 13:18:41 +02:00
Filip Hlasek
871f8f4e00
More efficient least common multiple. (#2281)
* More efficient least common multiple.

* lowest -> least

* integer division

* Update least_common_multiple.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-05 12:39:15 +02:00
Mark
a891f6802a
Procentual proximity scoring algorithm implemented (#2280)
* Procentual proximity scoring algorithm implemented

- added requested changes
- passed doctest

- passed flake8 test

* Apply suggestions from code review

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

* Function rename

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-04 22:11:07 +02:00
Rayvant Sahni
8e7aded87f
World covid19 stats (#2271)
* Josephus problem in Python

Added the code for the josephus problem in python using circular linked lists.

* Update josephus_problem.py

* Added World covid19 stats in web programming

* Delete josephus_problem.py

* Type hints, algorithmic functions should not print

Return a dict of world covid19 stats.  Move all printing into the main functions.

* Update world_covid19_stats.py

* Update world_covid19_stats.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-03 08:45:53 +02:00
TheSuperNoob
b2e8672f02
Fix doubly linked list algorithm (#2062)
* Fix doubly linked list algorithm

* Fix bug with insert_at_tail method

Create __str__() method for Node class and LinkedList class

* Simplify __str__() of LinkedList

Returns empty string if there are no elements in the list

* Fix description
2020-08-02 23:55:18 +08:00
poloso
b875f66f00
Deleted optimization empty directory (#2262) 2020-08-02 06:38:00 +02:00
Sven
1495382367
Fixed bug with incorrect LU decomposition (#2261)
* Fixed Bug #2257

* =

Co-authored-by: Svn-Sp <svn-sp@email>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-01 22:11:39 +02:00
spamegg
473072bd4f
added type hints and doctests to arithmetic_analysis/newton_method.py (#2259)
* added type hints and doctests to arithmetic_analysis/newton_method.py

Continuing #2128
Also changed some variable names, made them more descriptive.

* Added type hints and doctests to arithmetic_analysis/newton_method.py

added a type alias for Callable[[float], float] and cleaned up the exception handling

* added type hints and doctests to arithmetic_analysis/newton_method.py

improved exception handling

* Update newton_method.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-08-01 15:17:46 +02:00