Commit Graph

1840 Commits

Author SHA1 Message Date
Dhruv
69f9283825
Start running validate_solutions script for Travis CI (#3215)
* Removed print error_msgs at the end of test:

This was done only to reduce the message clutter produced by 60
failing tests. As that is fixed, we can produce the traceback in
short form and allow pytest to print the captured error message
output at the end of test.

* Start validate_solutions script for Travis CI

I am separating out the solution testing and doctest as validating
the solutions for the current number of solutions present is
taking 2 minutes to run.
2020-10-12 11:29:39 +05:30
PotatoK123
3859c65995
Added rail fence cipher (#3188)
* Added rail fence cipher

* Update rail_fence_cipher.py

* Update rail_fence_cipher.py
2020-10-12 10:37:45 +05:30
Christian Clauss
f7e7ad2ef6
CONTRIBUTING.md Jupyter files belong in the Jupyter repo. (#3211)
* CONTRIBUTING.md Jupyter files belong in the Jupyter repo.

* updating DIRECTORY.md

* Update CONTRIBUTING.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-12 08:17:26 +08:00
eba
3aef85bcec
Fix English grammar in computer vision (#3210) 2020-10-12 08:17:01 +08:00
Jr Miranda
c425010c44
Fetch CO2 emission information (#3182)
* Fetch CO2 emission information

* fix blank lines

* fix blank lines

* Add type hints for function return values

* Update co2_emission.py

* Update co2_emission.py

* Update co2_emission.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-12 01:31:56 +02:00
sarthaka1310
d02f6bbfbd
Added solution to Project Euler 69 (#2934)
* Added solution to Project Euler 69

* Accept edits from code review

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

* Added doctests

* Renaming and exception handling

* Apply suggestions from code review

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

* Edited mistake.

Co-authored-by: formal-acc <sarthak.agrawal@research.iiit.ac.in>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-11 23:38:30 +05:30
Simon Landry
60f9895685
Fixes: #3163 - Add new solution for problem 234 (#3177)
* Fixes: #3163 - Add new solution for problem 234

* Apply review suggestions
2020-10-11 23:16:16 +05:30
Michael D
f029fcef7b
Add solution for Project Euler problem 191 (#2875)
* Project Euler problem 191 solution

* Add type hints and reference links

* Address requested changes

- update documentation
- split out helper function but mark it with an underscore
- remove redundant comments or make them more explicit/helpful

* Address requested changes
2020-10-11 17:59:27 +05:30
Christian Clauss
731190842a
CODEOWNERS: Proper spelling of my userid (#3185)
* CODEOWNERS: Proper spelling of my userid

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-11 15:23:30 +05:30
Ravi Kandasamy Sundaram
2b5b2c6304
Added solution for Project Euler problem 119 (#2931)
Name: Digit power sum

Problem Statement: The number 512 is interesting because it is equal to the sum of its digits raised to some power: 5 + 1 + 2 = 8, and 83 = 512. Another example of a number with this property is 614656 = 284.
We shall define an to be the nth term of this sequence and insist that a number must contain at least two digits to have a sum.
You are given that a2 = 512 and a10 = 614656.
Find a30

Reference: https://projecteuler.net/problem=119

reference: #2695

Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
2020-10-10 23:29:02 +05:30
Dhruv
501a2ff430
[Project Euler] Fix code style for multiple problems (#3094)
* Fix code style for Project Euler problems:

- 13, 17, 21
- Default args
- Type hints
- File path

* Fix code style for multiple problems

* Made suggested changes
2020-10-10 21:23:17 +05:30
Dhruv
c961d5541f
Add CODEOWNERS file to TheAlgorithms/Python (#3147)
* Add CODEOWNERS file

* Commented out the non-assigned directory
2020-10-10 16:38:45 +02:00
Sandeep Gupta
c07b82fa63
Add Project Euler Problem 80 (#2885)
* adding solution to problem 80

* updating DIRECTORY.md

* fixing spell check

* updating sol as per comments

* Add reference link to the problem

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-10 17:06:25 +05:30
Tapajyoti Bose
3324bbb94b
Added sudoku type hints [Hacktober Fest] (#3124)
* chore(sudoku): added type hints [HACKTOBER-FEST]

* updating DIRECTORY.md

* chore: added matrix type alias

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 12:32:51 +05:30
Tapajyoti Bose
02d3ab81bd
feat: added prim's algorithm v2 (#2742)
* feat: added prim's algorithm v2

* updating DIRECTORY.md

* chore: small tweaks

* fixup! Format Python code with psf/black push

* chore: added algorithm descriptor

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 12:18:52 +05:30
Tapajyoti Bose
8bd4ca67be
Added all sub sequence type hints [Hacktober Fest] (#3123)
* updating DIRECTORY.md

* chore(all-subsequence): added type hints [HACKTOBER-FEST]

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 11:49:36 +05:30
Carlos Meza
927e14e7f2
Cleanup Project Euler Problem 01 (#2900)
* mv str statement into docstr

* rename var to avoid redefining builtin

* clean up module docstr
2020-10-10 11:03:00 +05:30
fpringle
c83e4b77c5
Added solution for Project Euler problem 125 (#3073)
* Added solution for Project Euler problem 125

* Fixed typos
2020-10-09 22:41:00 +05:30
Kushagra Bansal
ec9f6b6467
Created max_sum_sliding_window in Python/other (#3065)
* Add files via upload

* Update max_sum_sliding_window.py

* Update max_sum_sliding_window.py

* Update max_sum_sliding_window.py

* Added more tests

* Update max_sum_sliding_window.py

* Update max_sum_sliding_window.py
2020-10-09 17:51:04 +05:30
fa1l
10fe9d9be4
Coding style improvements for project_euler problem 45 & 16 (#3087)
* improvements for project euler task 45

* fixed documentation

* update pe_16/sol1.py

* update pe_16/sol2.py

* revert solution changes for sol1

* revert solution changes for sol2

* remove trailing spaces in sol1

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 12:09:44 +05:30
Juan José Torres
216a194e9a
[Project Euler] Fix code style for problems 15 and 34 (#3076)
* Add type hints and default args to problem 15

* Changes function's name to solution in problem 34

* Update sol1.py

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:46:55 +05:30
Nelson Stoik
1c0deb88ac
Coding style change for project_euler problem 36 and 35 (#3062)
* add problem url. Add typehint, default value and doctest

* run black

* add project url. add solution function for problem 35

* add space between imports on problem 35

* Update sol1.py

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:35:13 +05:30
Suyash Gupta
a3bbcd5f88
[Project Euler] Added type hints and refactored the code for Problem 14 (#3047)
* added type hints and refactored the code a bit

* made output statement more explicit

* used f-strings and updated type hints

* modified solution function to return an integer solution

* updated docstring

* Update sol1.py

* Update sol2.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:33:23 +05:30
fa1l
261be28120
Fix coding style for Project Euler problem 39 (#3023)
* improvements for project euler task 39

* add tests for solution()

* fixed a typo

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-09 08:13:54 +05:30
Aman Saxena
c9500dc89f
[Project Euler] Fix code style for problem 56 (#3050)
* rename method for project_euler/problem #56

* Update sol1.py

* Removed whitespaces

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 19:07:09 +05:30
Meysam
c2a5033f9e
graphs/kruskal: add a test case to verify the correctness, fix styles (#2443)
* test/graphs/kruskal: adding a test case to verify the correctness of the algorithm

Fixes #2128

* grahps/kruskal: running psf/black

* graphs/kruskal: read edges in a friendlier fashion

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

* Update minimum_spanning_tree_kruskal.py

* fixup! Format Python code with psf/black push

* Update test_min_spanning_tree_kruskal.py

* updating DIRECTORY.md

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-08 20:21:48 +08:00
kalpanajangra
7d0d77334f
Add Project Euler Problem 71: Fixes #2695 (#2785) 2020-10-08 19:55:23 +08:00
Nelson Stoik
e24248524a
Coding style with default argument for project_euler problem 27 (#3020)
* add default arguments and problem url

* Update and rename problem_27_sol1.py to sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 16:53:00 +05:30
Edward Nuno
899870be4c
Add style improvements to Project Euler problem 9 (#3046) 2020-10-08 16:51:32 +05:30
Joan
7d54056497
[Project Euler] Fix code style in Problem 41 (#2992)
* add problem title and link, fix f-string

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

* fix code style and improve doctests

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

* undo changes to the main call

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

* remove assignment operator in f-string

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

* add newline after first import to attempt to fix pre-commit workflow

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

* undo doctest changes, rename compute_pandigital_primes to solution

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

* update solution to return the actual solution instead of a list

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

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 13:57:07 +05:30
Dhruv
719c5562d9
Add default args and type hints for problem 7 (#2973)
- Add default argument values
- Add type hints
- Change one letter variable names to a more descriptive one
- Add doctest for `solution()`
2020-10-08 07:57:47 +02:00
Wen Hong
6541236fdf
Add solution method for project_euler/problem_37 (#2998)
* add solution method

* fix formatting
2020-10-08 09:27:14 +05:30
Edward Nuno
f3fe29cea1
Add style improvements to Project Euler problem 8 (#3001) 2020-10-08 09:21:17 +05:30
poloso
21581eae3b
Fix: Multiple errors in fibonacci search. (#2659)
* Fix: Multiple errors in fibonacci search.

- Test lists were not ordered, this is required for Fibonacci search
- Place documentation of function inside function
- Create multiple different tests including, float, char and negatives
- Add type hints in line with #2128

* Fix: sort of modules and delete typehint.

* Apply suggestions from code review

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

* Correct invocation of lru_cache.

* Add check for input in fibonacci and doctest.

* Correct typehints to comply to numpy style.

* Correct ValueError to TypeError.

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

* Correct doctest for TypeError.

* Rename  single letter names as mentioned in CONTRIBUTING.md.

* Fix: Bug in big lists.

* Remove print(.) in doctests.

* Refactor iterator to while loop.

* Update searches/fibonacci_search.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 09:06:19 +05:30
Nelson Stoik
ef53bbdf5a
Style Improvements for project_euler/problem_26 (#2958)
* 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

* add full problem statement and solution function with typehint and doctest

* renamed original function instead of adding new one

* don't alter original solution
2020-10-08 08:52:24 +05:30
Suyash Gupta
6a5a022082
Add type hints and default args for Project Euler problem 5 (#2982)
* add type hints and default args for problem 5

* Update sol1.py

* Update sol2.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-08 08:50:11 +05:30
Wen Hong
ff9be86390
Hacktoberfest 2020: Rename method for project_euler/problem_99 (#2981)
* name method solution in project_euler/problem99

* rename function
2020-10-07 20:46:11 +05:30
Joan
a698fa9a3f
[Project Euler] Fix code style in Problem 55 (#2985)
* fix code style and update problem description with link

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

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-07 20:39:36 +05:30
poloso
40db8c205f
Fix: Corrected test. List in test must be ordered. (#2632)
* Fix: Corrected test. List in test must be ordered.

* Add tests with big lists.
2020-10-07 19:57:19 +05:30
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