Commit Graph

2251 Commits

Author SHA1 Message Date
Joan
c14cfa32df
Address #2786 - Fix code style in Project Euler Problem 76 (#2978)
* fix code style in problem 76

Signed-off-by: joan.rosellr <joan.rosellr@gmail.com>

* Update sol1.py

* Update sol1.py

* Remove trailing whitespace

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-07 19:08:02 +05:30
JasirZaeem
05616ca38e
Update code style for Project Euler Problem 28 (#2976)
Add default arguments, typehints and rename solution function for Porject Euler Problem 28
2020-10-07 18:35:06 +05:30
Ron U
c510a7da7b
Add doomsday algorithm (#2903)
* Added doomsday algorithm

* Adding unit-tests to doomsday algorithm

* running black on doomsday

* adding doctest and fixing a black issue [doomsday]

* Update doomsday.py

* fixing black issue [doomsday]

* Update other/doomsday.py

* Update doomsday.py

* adding more doctests (following review comment) [doomsday]

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-07 20:22:56 +08:00
Dhruv
11a5afd8a1
Add type hints and default args for problem 20 (#2962)
- Improved variable names
- Added type hints
- Added default argument values for validate_solutions script
2020-10-07 17:59:55 +08:00
Joyce
e41d04112f
Fixes: #2630 Add doctests and support for negative numbers (#2626)
* add type hints to math/extended euclid

* math/extended euclid - add doctest

* math/extended euclid: remove manual doctest

* change algorithm for negative numbers

* improve naming of variables

* Update extended_euclidean_algorithm.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-07 15:23:14 +05:30
Edward Nuno
a5000d32ed
Add style improvements to solutions for Project Euler Problem 04 (#2945)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02

* Add style improvements for first solution of PE Problem 02

* Add default arg and typehints for second solution of PE Problem 02

* Add default arg for third solution of PE Problem 02

* Add style improvements for 1st soln of PE problem 03

* Add default arg and typehints for 2nd soln of PE problem 03

* Add default arg for 3rd soln of PE problem 03

* Remove unnecessary newlines

* Remove unnecessary newlines

* Fix end of file for 2nd soln in PE problem 03

* Add style improvements to solutions for PE problem 04

* Restore original newlines in soln for PE problem 04

* Fix punctuation in docstring for PE problem 04

* Restore solution bodies for PE problem 04

* Expand variable names for 2nd soln of PE problem 04
2020-10-07 10:33:34 +05:30
Dhruv
ddf83ec886
Add default arguments for Project Euler problem 6 (#2957)
- Add default arguments to solution function
- Add link to Project Euler problem 6
- Add doctest for testing `solution()`
- Removed test_solutions.py as it is redundant
2020-10-07 10:17:43 +05:30
Nelson Stoik
4d4ce400ec
Add typehints and default input for project_euler/problem_25 (#2901)
* add typehints and docstrings

* add typehint and default value

* add typehint and default value. Removed unused variable.

* do not modifiy the given solution

* add doctests

* update sol1 after running black

* add typehint, docstring, and doctest

* update sol2 after running black
2020-10-07 09:27:25 +05:30
Noah H
91ad30c2b0
Bring problem_29 solution in line with project style guidelines (#2949) 2020-10-07 08:33:03 +05:30
Edward Nuno
54401387a8
Hacktoberfest 2020: Add style improvements for Project Euler Problem 03 (#2917)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02

* Add style improvements for first solution of PE Problem 02

* Add default arg and typehints for second solution of PE Problem 02

* Add default arg for third solution of PE Problem 02

* Add style improvements for 1st soln of PE problem 03

* Add default arg and typehints for 2nd soln of PE problem 03

* Add default arg for 3rd soln of PE problem 03

* Remove unnecessary newlines

* Remove unnecessary newlines

* Fix end of file for 2nd soln in PE problem 03
2020-10-06 20:24:39 +05:30
Vladimir Evgrafov
e74adc4a6d
Project Euler Problem 10: style improvements (#2924)
Rename the main solution functions to solution.
Rename prime chec functions to is_prime.
Add default args, typehints, expand variable names.
2020-10-06 17:48:07 +05:30
Dmytro Litvinov
000cedc07f
Add type hints for "strings" folder (#2882)
* Add type hints for strings/ folder

* Rerun other checks

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-06 14:01:15 +05:30
Edward Nuno
f36a2f621e
Hacktoberfest 2020: Apply style guidelines for Project Euler problem_02 (#2898)
* Fix typehints in project_euler/problem01

Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01

* Add default args, typehints, and expand variable names for PE prob 02
2020-10-06 10:04:16 +05:30
Utkarsh Chaudhary
a8ad2d10b4
Add Project Euler 120 solution (#2887) 2020-10-06 08:41:15 +05:30
Noah H
a56e548264
Bring problem_30 solution in line with project style guidelines (#2896) 2020-10-06 08:21:39 +05:30
Edward Nuno
edf2cd2b0c
Fix typehints in project_euler/problem01 (#2891)
Squashed commit of the following:

commit 6801d073b31bf702814861cd3b07b634ca295bfa
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 16:40:10 2020 -0700

    Fix typehints in project_euler/problem01

commit 29afc3af114abd1b99dc3f7c8fc99128229db131
Author: Archaengel <god11341258@gmail.com>
Date:   Mon Oct 5 15:06:34 2020 -0700

    Add typehints and default argument for project_euler/problem_01
2020-10-06 08:12:16 +05:30
Dmytro Litvinov
7df91e681a
Add type hints for searches/ternary_search.py (#2874) 2020-10-05 23:14:35 +05:30
Sherman Hui
477b2c24b8
Hacktoberfest: Update Linked List - print_reverse method (#2792)
* chore: update print_reverse helper method

Use a generator expression instead of slicing
`elements_list` to improve the space and time complexity
of `make_linked_list` to O(1) space and O(n) time
by avoiding the creation a shallow copy of `elements_list`.

* fix: add type checking and argument typing

Add argument typing to all methods in `print_reverse`

Add doctest to helper function `make_linked_list` and
basic edge case tests to `print_reverse`

* test: add `print_reverse` test

Fix doctest syntax and remove edge case tests that are covered
by typed arguments.

Add `print_reverse` test that expects the correct values are printed
out by adding a `test_print_reverse_output` helper function.

* format code

Co-authored-by: shellhub <shellhub.me@gmail.com>
2020-10-05 19:08:57 +08:00
Du Yuanchao
437c725e64
Fixed allocation_number (#2768)
* fixed allocation_number

* fixed pre-commit

* fixed line too long

* fixed bug
2020-10-05 09:17:46 +05:30
Iqrar Agalosi Nureyza
e040ad2a01
Add a solution for Project Euler 49 (#2702)
* added doctests in modular_exponential.py

* added doctests in modular_exponential.py

* added URL link

* updating DIRECTORY.md

* Add problem 49 solution

* updating DIRECTORY.md

* Fix several mistakes

These fixes are intended to follow the CONTRIBUTING.md

* Move the import statements lower

* Update project_euler/problem_49/sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-05 08:27:09 +05:30
Dhruv
b934da4516
Fix pre-commit error in GitHub action file (#2765) 2020-10-04 21:16:13 +05:30
Sabari Ganesh
fb9b9ecccf
Update area.py (#2524)
* Update area.py

Added Area for Rhombhus

* Update area.py

Added rhombhus area. And fixed some gaps error.

* Update area.py

Added Rhombhus area.

* Update area.py

Fixed suggested changes
2020-10-04 22:20:47 +08:00
Richard Wheatley
3b0169549e
Create auto_close_empty_issues.yml (#2756)
* Create auto_close_empty_issues.yml

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-04 16:20:36 +02:00
Sabari Ganesh
e9865ae611
Update temperature_conversions.py (#2522)
* Update temperature_conversions.py

Added Reaumur scale unit conversions.

* Update temperature_conversions.py

* Update temperature_conversions.py
2020-10-03 22:02:58 +05:30
Du Yuanchao
43f92490fe
Update insert sort (#2493)
* delete duplicate file
update insert sort

* rename

* fixed error

* using enumerate()
2020-10-03 20:49:08 +05:30
Kushagra Bansal
6a395456ee
Created problem_112.py in project_euler (#2532)
* Add files via upload

* Create __init__.py

* Update and rename project_euler/problem_112.py to project_euler/problem_112/sol1.py

* Update project_euler/problem_112/sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Update sol1.py

* Update sol1.py

* Update project_euler/problem_112/sol1.py

Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>

* Update project_euler/problem_112/__init__.py

Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>

* Update __init__.py

* Update __init__.py

* Update __init__.py

* delete __init__.py content

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
Co-authored-by: Du Yuanchao <shellhub.me@gmail.com>
2020-10-03 16:38:56 +08:00
Dmytro Litvinov
5903948cf3
Fixes: #2404. Fix PIL DeprecationWarnings in pytest output (#2678) 2020-10-03 09:22:22 +02:00
Du Yuanchao
9b3f7c36d0
Test random input for bubble sort (#2492) 2020-10-02 13:55:58 +08:00
Eugeniy Orlov
2388bf4e17
Add type hints to strings/min_cost_string_conversion.py (#2337)
* done

* add types for local variables

* Revert "add types for local variables"

This reverts commit 971c15673b.

* rename variables

* Update strings/min_cost_string_conversion.py

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

* rename strings

* use flake8

* Update strings/min_cost_string_conversion.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-01 09:04:31 +08:00
Du Yuanchao
2fa009aa53
Fix bucket sort (#2494)
* fixed bucket sort

* delete blank line
2020-10-01 08:53:42 +08:00
Christian Clauss
ddfa9e4f22
Travis CI: Remove redundant tests (#2523)
* Travis CI: Remove redundant tests

* fixup! before_script

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-30 19:26:38 +02:00
Dhruv
7a502708e0
Add badges for code style and pre-commit in README.md (#2516)
* Add badges for code style and pre-commit

* Update badge style to flat-square

* Update Gitpod logo style to flat-square
2020-09-30 16:40:20 +02:00
Dhruv
acaeb22bbd
Add GitHub action for pre-commit (#2515)
* Add GitHub action file for pre-commit

* Fix errors exposed by pre-commit hook:

- Remove executable bit from files without shebang. I checked those
  file and it was not needed.
- Fix with black

* Apply suggestions from code review

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-30 15:23:34 +02:00
Dhruv
ae65f55de3
Add pre-commit hook for TheAlgorithms/Python (#2511)
* Add pre-commit basic config file

* Add pre-commit to requirements.txt

* Small tweaks and use stable for black

* Fix isort section in pre-commit-config file

* Fix errors and EOF only for Python files
2020-09-30 10:39:14 +02:00
Dhruv
0a42ae9095
Fix all errors mentioned in pre-commit run (#2512)
* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
2020-09-30 10:38:00 +02:00
YOGESHWARAN R
e6e2dc69d5
Create instagram_crawler.py (#2509)
* Create instagram_crawler.py

* codespell --ignore-words-list=followings

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update web_programming/instagram_crawler.py

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

* Update instagram_crawler.py

* Add doctests

* fixup! except (json.decoder.JSONDecodeError, KeyError):

* if getenv("CONTINUOUS_INTEGRATION"): return

* Update instagram_crawler.py

* Update web_programming/instagram_crawler.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* added fake_useragent

* Update instagram_crawler.py

* Comment out doctests

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-09-29 18:04:55 +02:00
Lewis Tian
e166350509
Update sorts/quick_sort_3_partition.py (#2507)
* Update sorts/quick_sort_3partition.py

Another quick sort algorithm, returns a new sorted list

* Update sorts/quick_sort_3_partition.py

rename quick_sort_3partition to quick_sort_3part

* Update sorts/quick_sort_3_partition.py

rename quick_sort_3part to three_way_radix_quicksort
Three-way radix quicksort:
https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort
First divide the list into three parts.
Then recursively sort the "less than" and "greater than" partitions.

* Update sorts/quick_sort_3_partition.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-29 13:55:48 +02:00
Guillaume Rochedix
d95d643351
Heaps algorithm (#2475)
* heaps_algorithm: new algo

* typo

* correction doctest

* doctests: compare with itertools.permutations

* doctest: sorted instead of set

* doctest

* doctest

* rebuild
2020-09-29 12:39:07 +02:00
Guillaume Rochedix
04322e67e5
Heaps algorithm iterative (#2505)
* heap's algorithm iterative

* doctest

* doctest

* rebuild
2020-09-29 12:38:12 +02:00
Dhruv
9016fe192f
Fix imports for all namespace packages (#2506)
* Fix imports as they're namespace packages

* Fix import for scripts/validate_filenames.py

* Fix path in doctest
2020-09-28 23:41:04 +02:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Lewis Tian
121dddc7f2
Update maths/area.py (#2501)
the parameters of geometric shapes should be non-negative values
2020-09-28 22:40:47 +08:00
xcodz-dot
1b637ba8ed
Create vector3_for_2d_rendering.py (#2496)
* Create vector3_for_2d_rendering.py

Edited for passing travis test

* Delete vector3_for_2d_rendering.py

* Create vector3_for_2d_rendering.py

* Update vector3_for_2d_rendering.py

Compressed the line 19 to 28 into 19 to 21

* Update vector3_for_2d_rendering.py

* Update vector3_for_2d_rendering.py

* Update vector3_for_2d_rendering.py

completly corrected pep8 errors using Pycharm IDE

* Update vector3_for_2d_rendering.py

* Update graphics/vector3_for_2d_rendering.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Update graphics/vector3_for_2d_rendering.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Update graphics/vector3_for_2d_rendering.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>

* Update vector3_for_2d_rendering.py

* Update vector3_for_2d_rendering.py

* Update graphics/vector3_for_2d_rendering.py

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

* Update graphics/vector3_for_2d_rendering.py

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

* Apply suggestions from code review

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

* Update vector3_for_2d_rendering.py

Added A few extra names to __author__ 😄

* Update vector3_for_2d_rendering.py

Used Pycharm to fix PEP8 errors, doctest errors

* Update vector3_for_2d_rendering.py

Added enough doctests

* Update graphics/vector3_for_2d_rendering.py

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

* Remove second main()

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-28 11:43:34 +02:00
Dhruv
ceacfc6079
Add algorithm for testing Project Euler solutions (#2471)
* Add file for testing Project Euler solutions

* Remove the importlib import

* Update project_euler/solution_test.py

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

* Small tweaks to project_euler/solution_test.py

* Test Project Euler solutions through Travis

* Improved testing for Project Euler solutions:

- Renamed file so that it isn't picked up by pytest
- Fail fast on validating solutions through Travis CI

* Update validate_solutions.py

* Use namedtuple for input parameters and answer

- Remove logging
- Remove unnecessary checks for PROJECT_EULER_PATH as Travis CI
  picks up the same path

* Fix flake8 errors: line too long

* Small tweaks to validate_solutions.py

* Add all answers & back to using dictionary

* Using pytest for testing Project Euler solutions

- As we want to fail fast on testing solutions, we need to test using
  this script first before we use tests written by the author.
- As pytest stops testing as soon as it receives a traceback, we need to
  use pytest-subtests to tell pytest to test all the iterations for the
  function with given parameters.

* Print error messages in oneline format

* Separated answers into a separate file:

- Add custom print function to print all the error messages at the
  end of all the tests
- Let Travis skip if this failed

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-28 08:18:19 +02:00
Dhruv
187e8ccc95
Small fix (#2498) 2020-09-27 15:05:09 +02:00
Du Yuanchao
8904af98a1
Optimization for pangram string (#2473)
* optimization for pangram string

* fixup! Format Python code with psf/black push

* Update strings/check_pangram.py

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

* updating DIRECTORY.md

* Update strings/check_pangram.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-26 22:58:59 +08:00
Abdoulaye Balde
7446e69571
Gradient Boosting Regressor (#2298)
* Stock market prediction using greadient boosting

* To reverse a string using stack

* To reverse string using stack

* Predict Stock Prices Python & Machine Learning

* Gradient boosting regressor on boston dataset

* Gradient boosting regressor implementation

* Gradient boosting regressor

* Gradient boosting regressor

* Gradient boosting regressor

* Removing files

* GradientBoostingRegressor example

* Demo Gradient Boosting

* Demo Gradient boosting

* demo of gradient boosting

* gradient boosting demo

* Fix spelling mistake

* Fix formatting

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-09-26 16:58:29 +02:00
Du Yuanchao
7f48bb8c95
Updated circular_linked_list (#2483)
* Updated circular_linked_list

* fixup! Format Python code with psf/black push

* Update data_structures/linked_list/circular_linked_list.py

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

* updating DIRECTORY.md

* delete print_list()

* test is_empty()

* test is_empty return False

* fixup! Format Python code with psf/black push

* fixed indentation

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-26 22:57:09 +08:00
Christian Clauss
db0db01d87
Use self-documenting option instead of cryptic option (#2487)
* Use self-documenting option instead of cryptic option

@mateuszz0000 Your review, please.  Pretend that you do not know what `-L` stands for.  How many keystrokes and clicks does it take to confirm the purpose of this option?

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-26 16:54:41 +02:00
Du Yuanchao
72fe611462
Updated lower and upper (#2468)
* update lower and upper

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-26 01:58:40 +08:00