Commit Graph

180 Commits

Author SHA1 Message Date
Christian Clauss
0a0f4986e4
Upgrade GitHub Actions (#6236)
* Upgrade GitHub Actions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-07-07 05:25:25 +02:00
Vcrostin
69cde43ca1
make DIRECTORY.md paths relative Fixes (#6179) (#6190) 2022-06-22 12:01:05 +08:00
kugiyasan
8004671b98
Add Project Euler 68 Solution (#5552)
* updating DIRECTORY.md

* Project Euler 68 Solution

* updating DIRECTORY.md

* Project Euler 68 Fixed doctests, now at 93% coverage

* Update sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: kugiyasan <kugiyasan@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-05-27 03:24:23 +08:00
Maxim Smolskiy
de4d98081b
Improve Project Euler problem 145 solution 1 (#6141)
* updating DIRECTORY.md

* Improve solution

* updating DIRECTORY.md

* Fix

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-05-24 09:20:47 +08:00
Lukas
7a9b3c7292
Added average absolute deviation (#5951)
* Added average absolute deviation

* Formats program with black

* reruns updated pre commit

* Update average_absolute_deviation.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2022-02-13 18:20:19 +01:00
Christian Clauss
f707f6d689
Upgrade to Python 3.10 (#5992)
* Upgrade to Python 3.10

* Upgrade to Python 3.10

* mypy || true

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-02-13 06:57:44 +01:00
Christian Clauss
24d3cf8244
The black formatter is no longer beta (#5960)
* The black formatter is no longer beta

* pre-commit autoupdate

* pre-commit autoupdate

* Remove project_euler/problem_145 which is killing our CI tests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-01-30 20:29:54 +01:00
Michael Currin
7423875cef
ci: add mkdir step for mypy (#5927)
* ci: add mkdir step for mypy

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-01-26 23:35:51 +08:00
Christian Clauss
1ae5abfc3c
Replace typing.optional with new annotations syntax (#5829)
* Replace typing.optional with new annotations syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-17 04:43:02 +01:00
Rohan R Bharadwaj
e9882e41ba
[mypy] Fix matrix_operation.py (#5808)
* Update matrix_operation.py

* Update mypy.ini

* Update DIRECTORY.md

* formatting

* Update matrix_operation.py

* doctest for exception

* A bit more...
2021-11-10 16:22:52 +01:00
Nivas Manduva
c3d1ff0ebd
Add Jacobi Iteration Method (#5113)
* Added Jacobi Iteration Method

Added this method in arithmetic_analysis folder. This method is used to solve system of linear equations.

* Added comments

* Added reference link

* Update jacobi_iteration_method.py

* Changes for codespell test

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* updating DIRECTORY.md

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update arithmetic_analysis/jacobi_iteration_method.py

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

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* Update jacobi_iteration_method.py

* fix styles

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-11-09 22:40:57 +08:00
Maxim Smolskiy
0b8d6d70ce
Add Project Euler problem 205 solution 1 (#5781)
* updating DIRECTORY.md

* Add solution

* updating DIRECTORY.md

* Fix

* Fix

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-09 22:25:29 +08:00
Dylan Buchi
ac4bdfd66d
[mypy] Fix type annotations in graphs/boruvka.py (#5794)
* Fix type annotations in boruvka.py

* Remove graphs/boruvka.py|

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-08 21:47:09 +08:00
Rohan R Bharadwaj
db5aa1d188
Add equated_monthly_installments.py in Financials (#5775)
* Add equated_monthly_installments.py in Financials

* Formatting

* More formatting, Descriptive names

* Errors with name change

* Formatting

* Formatting, Naming Error

* dedent

* Update DIRECTORY.md
2021-11-07 15:40:23 +01:00
Maxim Smolskiy
1a43c92c77
Improve Project Euler problem 043 solution 1 (#5772)
* updating DIRECTORY.md

* Fix typo

* Improve solution

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-05 20:44:24 +01:00
Souvik Ghosh
0ea5c734e1
sock_merchant.py: Matching socks by color (#5761)
* Python file for finding number of pairs

* updating DIRECTORY.md

* fixed iterative_pair.py

* further fixed with type casting

* fixed naming conventions

* further fixed with naming convention

* documented done

* build issue fixed

* updating DIRECTORY.md

* Revert "documented done"

This reverts commit 3be15ca374.

* Update canny.py

* Update test_digital_image_processing.py

* Update sobel_filter.py

* requirements.txt fixed

* keras<2.7.0

* Update sock_merchant.py

* doctest with black fixed

* Update sock_merchant.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-11-03 21:24:50 +01:00
Christian Clauss
74f4967126
Fix comment (#5742)
* Fix comment

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-01 18:07:47 +01:00
Edward Nuno
94f38dd88c
[mypy] Fix type annotations for linked_stack.py (#5576)
* Fix type annotations for linked_stack.py

* Replace Optional with inline union type

* Rename linked_stack to stack_with_singly_linked_list

* Rename stack_using_dll to stack_with_doubly_linked_list

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-31 17:03:03 +01:00
poloso
61e1dd27b0
[mypy] Fix type annotation in euler_method.py (#5649)
* [mypy] Fix type annotation in euler_method.py

In line with issue #4052.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-28 22:31:32 +02:00
Naveen Namani
11a15cc584
Add solution for Project Euler problem 67 (#5519)
* New solution for Euler problem 67

A faster and memory efficient solution based on the template of sol1.py.
Modified the solution to be more memory efficient while reading and generating the array
and during the solution finding.
No conditions and straightforward logic.

* added return type hint

* Update project_euler/problem_067/sol2.py

Preferring comprehensions over map

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

* Update sol2.py

Self explanatory variable names

* Updated sol2 to problem 067 in directory

* Update project_euler/problem_067/sol2.py

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

* Update project_euler/problem_067/sol2.py

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

* Fixed extra line

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-28 19:27:14 +02:00
Christian Clauss
477cc3fe59
Add pyupgrade to pre-commit (#5638)
* Add pyupgrade to pre-commit

* Remove unused imports

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-28 16:45:59 +02:00
Prakhar Gurunani
329feb4928
Add Project Euler Problem 078 solution 01 (#5565)
* Create sol1.py

* updating DIRECTORY.md

* Create __init__.py

* Add docstring

* Reformat with black

* Fix flake8 issues

* Add EOL

* Fix formatting issues

* Add docstring

* Add func return type

* Change return type

* Remove test print statement

* Reformat code

* Fix return types

* Break loop

* Update doctest sol

* Update project_euler/problem_078/sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>

* Added doctest and changed return type

* Add int()

* Fix flake8 issues

* Use argument instead of fixed constant

* Update sol1.py

* fix sol1.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-10-27 17:19:04 +08:00
Christian Clauss
cb4dc19723
Financial: principle -> principal (#5614)
* Financial: principle -> principal

The originally invested amount of money: `principal`
-- https://www.grammarly.com/blog/principle-principal/

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-27 00:41:32 +08:00
Prakhar Gurunani
827b8f04a4
Get top 10 HN posts (#5604)
* updating DIRECTORY.md

* updating DIRECTORY.md

* Create get_top_hn_posts.py

* updating DIRECTORY.md

* Add return type and desc

* Add texttable

* Update web_programming/get_top_hn_posts.py

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

* Update web_programming/get_top_hn_posts.py

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

* Get top 10 posts

* Update get_top_hn_posts.py

* Don't use texttable

* Setup doctest

* Fix pre-commit issues

* Remove print statement

* Add hackernews_top_stories_as_markdown()

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-26 15:13:23 +02:00
Christian Clauss
366a0f1839
Fix validate_initial_digits of credit_card_validator.py (#5600)
* Fix validate_initial_digits of credit_card_validator.py

@Bhargavishnu I think that I broke the logic of validate_initial_digits which should require that credit_card_number[0] is 3 before checking that credit_card_number[1] is 4, 5, or 7.  Please verify the new changes and the new test cases to make sure that this is correct.  Thanks!

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-26 14:32:34 +02:00
Prakhar Gurunani
f93c7d4d80
Get user tweets (#5593)
* updating DIRECTORY.md

* Create get_user_tweets.py

* updating DIRECTORY.md

* Reformat code with black

* Add argument type

* Add return type

* Add tweepy

* Fix isort issues

* Fix flake8 issues

* WIP: doctest

* Doctest setup and format with pre-commit

* Remove doctests

* Update web_programming/get_user_tweets.py

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

* Update get_user_tweets.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-26 10:05:13 +02:00
Francisco Perez
568c107e68
add bin_to_hexadecimal (#5156) 2021-10-25 15:58:24 +08:00
Christian Clauss
bd9464e4ac
mandelbrot.py: Commenting out long running tests (#5558)
* mandelbrot.py: Commenting out long running tests

* updating DIRECTORY.md

* Comment out 9 sec doctests

* Update bidirectional_breadth_first_search.py

* Comment out slow tests

* Comment out slow (9.15 sec) pytests...

* # Comment out slow (4.20s call) doctests

* Comment out slow (3.45s) doctests

* Update miller_rabin.py

* Update miller_rabin.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-23 18:15:30 +02:00
Sherman Hui
629848e372
[mypy] Fix type annotations in data_structures/binary_tree (#5518)
* fix: fix mypy errors

Update binary_search_tree `arr` argument to be typed as a list
within `find_kth_smallest` function

Update return type of `merge_two_binary_trees` as both inputs can
be None which means that a None type value can be returned from
this function

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-22 16:07:05 +02:00
John Law
c0acfd46cb
Fix factorial issues (#5496)
* updating DIRECTORY.md

* pass integer to `math.factorial` in `project_euler/problem_015`

* remove duplicated factorial function

* updating DIRECTORY.md

* Update maths/factorial_iterative.py

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

* Update factorial_iterative.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-21 15:06:32 +08:00
Christian Clauss
f7804334f1
length_conversion.py: Deal with uppercase and abbreviations (#5433)
* length_conversion.py: Deal with uppercase and abbreviations

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 11:11:49 +02:00
Christian Clauss
aa0ace4df7
Remove exception detail from doctest (#5430)
* Remove exception detail from doctest

These details are configuration dependant so should be removed according to https://docs.python.org/3/library/doctest.html

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-19 08:05:20 +02:00
John Law
4bf2eedd3c
[mypy] fix mypy error in Project Euler Problem 092 solution 1 (#5357)
* fix mypy error

* updating DIRECTORY.md

* simplify code

* run black

* fix doc consistency

* Fix doc

* fix doc

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-17 08:07:45 +02:00
Christian Clauss
8dc7cdbc57
Add tests to morse_code.py (#5337)
* Add tests to morse_code.py

@dhruvmanila @poyea Your reviews, please.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-16 18:57:38 +02:00
Christian Clauss
ca842b4add
It is OK to test ./scripts (#5290)
* It is OK to test ./scripts

* updating DIRECTORY.md

* Update build.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-14 18:19:47 +02:00
poloso
9586a6a98e
Change comments for improved consistency (#5223)
* Change comments for improved consistency

https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L56
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L80
https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md#L87

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-12 00:44:38 +08:00
Christian Clauss
15d1cfabb1
from __future__ import annotations (#4763)
* from __future__ import annotations

* updating DIRECTORY.md

* from __future__ import annotations

* from __future__ import annotations

* Update xor_cipher.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-22 23:11:51 +02:00
Christian Clauss
dc07a85076
Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py (#4665)
* Update and rename check_valid_ip_address.py to is_ip_v4_address_valid.py

New test cases that the algorithm must detect:
* [ ] an octet much bigger than 255
* [ ] an octet is negative
* [ ] number of octets is less than 4
* [ ] number of octets is greater than 4
* [ ] an octet is a letter

* updating DIRECTORY.md

* Add two more tests to is_ip_v4_address_valid.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2021-09-23 02:03:11 +08:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
Christian Clauss
78a5d3a558
boruvka.py: A few simplifications and f-strings (#4660)
* boruvka.py: A few simplifications and f-strings

Python f-strings simplify the code and [should speed up execution](https://www.scivision.dev/python-f-string-speed). 

@srkchowdary2000 Your review, please.

* updating DIRECTORY.md

* fixup! Streamline the test

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-08-24 15:27:31 +02:00
fpringle
8c13a7786f
feat: add solution for Project Euler problem 144 (#4280)
* Added solution for Project Euler problem 144

* updating DIRECTORY.md

* Better variable names

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-07-08 14:05:10 +05:30
Aniruddha Bhattacharjee
b743e44259
Wavelet tree (#4267)
* Added the matrix_exponentiation.py file in maths directory

* Implemented the requested changes

* Update matrix_exponentiation.py

* resolve merge conflict with upstream branch

* add new line at end of file

* add wavelet_tree

* fix isort issue

* updating DIRECTORY.md

* fix variable names in wavelet_tree and correct typo

* Add type hints and variable renaming

* Update data_structures/binary_tree/wavelet_tree.py

Add doctests to placate the algorithm-bot, thanks to @cclauss.

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

* Move doctest to individual functions and reformat code

* Move common test array to the global scope and reuse in tests

* MMove test array to global scope and minor linting changes

* Correct the failing pytest tests

* MUse built-in list for type annotation

* Update wavelet_tree.py

* types-requests

* updating DIRECTORY.md

* Update wavelet_tree.py

* # type: ignore

* # type: ignore

* Update decrypt_caesar_with_chi_squared.py

* ,

* Update decrypt_caesar_with_chi_squared.py

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Aniruddha Bhattacharjee <aniruddha@Aniruddhas-MacBook-Air.local>
2021-06-08 22:49:33 +02:00
Christian Clauss
71b458cefe
Rename harriscorner.py to harris_corner.py (#4470)
* Rename harriscorner.py to harris_corner.py

* updating DIRECTORY.md

* Rename meanthreshold.py to mean_threshold.py

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-05-31 21:19:09 +05:30
Dhruv Manilawala
ac29f70755
fix(action): correct indentation for types key (#4445)
* fix(action): correct indentation for types key

* updating DIRECTORY.md

* refactor: add quotes around name key

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-05-21 19:03:56 +05:30
algobytewise
1a39970538
Add rgb_hsv_conversion.py (#4334)
* Add rgb_hsv_conversion.py

* updating DIRECTORY.md

* snake-case

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-04-23 08:24:01 +02:00
algobytewise
536fb4bca4
Add algorithm for N-body simulation - retry (#4298)
* add n_body_simulation.py

* updating DIRECTORY.md

* Rename other/n_body_simulation.py to physics/n_body_simulation.py

* updating DIRECTORY.md

* Update build.yml

* refactor examples & add doctests

* removed type-hints from self-parameter

* Apply suggestions from code review

* Update physics/n_body_simulation.py

* Update physics/n_body_simulation.py

* Update physics/n_body_simulation.py

* Don't forget self

* Fix velocity

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-04-04 13:23:48 +02:00
algobytewise
35901eb6fe
Move: traversals/binary_tree_traversals.py --> searches/binary_tree_traversal.py (#4295)
* Rename traversals/binary_tree_traversals.py to searches/binary_tree_traversal.py

* updating DIRECTORY.md

* Delete traversals directory

* Update build.yml

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-27 10:18:48 +01:00
algobytewise
a8db5d4b93
[mypy] fix compression folder (#4290)
* Update lempel_ziv.py

* Update build.yml

* updating DIRECTORY.md

* fix doctest in 2_hidden_layers_neural_network.py

* one more doctest

* simplified tests

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-22 19:24:05 +01:00
DevanshiPatel18
dd757dce38
feat: Add greedy_coin_change.py algorithm (#3805)
* Hacktoberfest: Add greedy_coin_change.py file 

added the file in greedy_methods folder to implement the same method

Altered the code according to the changes that were requested.

* Added doctests.

doctests added to the function find_minimum_change.

* Added Greedy change file in Maths folder.

* updating DIRECTORY.md

* Deleted Greedy Method Folder

* updating DIRECTORY.md

* Update greedy_coin_change.py

* fix: black formatting issues

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2021-03-20 11:48:38 +05:30
fpringle
89a43c81e5
feat: Add solution for Project Euler Problem 121 (#4261)
* Added solution for Project Euler problem 121

* Updated typing for 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-03-20 11:29:48 +05:30