Commit Graph

166 Commits

Author SHA1 Message Date
PetitNigaud
99adac0eb1
Add first solution for Project Euler Problem 207 (#3522)
* add solution to Project Euler problem 206

* Add solution to Project Euler problem 205

* updating DIRECTORY.md

* updating DIRECTORY.md

* Revert "Add solution to Project Euler problem 205"

This reverts commit 64e3d36cab.

* Revert "add solution to Project Euler problem 206"

This reverts commit 53568cf4ef.

* add solution for project euler problem 207

* updating DIRECTORY.md

* add type hint for output of helper function

* Correct default parameter value in solution

* use descriptive variable names and remove problem solution from doctest Fixes: #2695

Co-authored-by: nico <esistegal-aber@gmx.de>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-29 12:34:42 +05:30
fpringle
9971f981a1
Added solution for Project Euler problem 87. (#3141)
* Added solution for Project Euler problem 87. Fixes: #2695

* Update docstring and 0-padding in directory name. Reference: #3256
2020-10-29 12:19:33 +05:30
sharmapulkit04
e172a8b08b
Hacktoberfest: Added first solution to Project Euler problem 58 (#3599)
* Added solution to problem 58

* Update sol1.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-29 10:03:55 +08:00
John Law
a5aef147e9
Fix Project Euler Readme (#3754)
* Fix Project Euler Readme

* updating DIRECTORY.md

* Update CONTRIBUTING.md

* spacing

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-26 21:18:57 +05:30
Ayoub Chegraoui
3a191d9a7c
Add solution to Project Euler problem 81 (#3408)
* Add solution to problem 81 - project euler

* Update project_euler/problem_081/sol1.py

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

* Update project_euler/problem_081/sol1.py

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

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-10-25 09:36:31 +05:30
Michael D
98e9d6bdb6
Fix style of the first ten solutions for Project Euler (#3242)
* Fix style of the first ten solutions for Project Euler

- Unify the header docstring, and add reference URLs to wikipedia
  or similar
- Fix docstrings to be properly multilined
- Add newlines where appropriate
- Add doctests where they were missing
- Remove doctests that test for the correct solution
- fix obvious spelling or grammar mistakes in comments and
  exception messages
- Fix line endings to be UNIX. This makes two of the files seem
  to have changed completely
- no functional changes in any of the solutions were done
  (except for the spelling fixes mentioned above)

* Fix docstrings and main function as per Style Guide
2020-10-25 08:53:16 +05:30
Dhruv Manilawala
b97529dd88
Move validate_solutions and add durations flag to pytest.ini (#3704)
* Move PE validate_solutions to scripts/ directory

* Update pytest.ini file with durations settings

* Remove codespell and autoblack workflow file

* Dependent changes to test config files

* Update pytest.ini
2020-10-24 19:07:33 +05:30
fpringle
409438d250
Add solution for Project Euler problem 38. (#3115)
* Added solution for Project Euler problem 38. Fixes: #2695

* Update docstring and 0-padding in directory name. Reference: #3256

* Renamed is_9_palindromic to is_9_pandigital.

* Changed just-in-case return value for solution() to None.

* Moved exmplanation to module-level docstring and deleted unnecessary import
2020-10-24 08:12:15 +05:30
Peter Yao
20260d2b9c
Add Project Euler 65 Solution (#3035)
* Add solution for Project Euler 65,

* Add URL to problem 65 and don't pass in parameter to solution()

* Remove solution() tests

* Add tests for solution(), add fstring and positional arg for solution

* Rename directory and problem number to 065

* Remove directory

* Move up explanation to module code block

* Move solution() below helper function, rename variables
2020-10-24 07:55:15 +05:30
Christian Clauss
9b95e4f662
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 12:46:14 +02:00
Benjamin Smith
58875674da
Project Euler 57 - Square root convergents (#3259)
* include solution for problem 57

* fix line to long errors

* update filenames and code to comply with new regulations

* more descriptive local variables
2020-10-16 21:17:35 +05:30
fpringle
9643d3060d
Add solution for Project Euler problem 75. (#3129)
* Added solution for Project Euler problem 75. 

* Added doctest for solution() in project_euler/problem_75/sol1.py

* Update docstring and 0-padding of directory name. Reference: #3256

* More descriptive variable names

* Moved solution explanation to module-level docstring
2020-10-16 16:00:45 +05:30
fpringle
b74f3a8b48
Add solution for Project Euler problem 91. (#3144)
* Added solution for Project Euler problem 91. Reference: #2695

* Added doctest for solution() in project_euler/problem_91/sol1.py

* Update docstring and 0-padding in directory name. Reference: #3256

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-16 15:44:06 +05:30
fpringle
b96e6c7075
Add solution for Project Euler problem 174. (#3078)
* Added solution for Project Euler problem 174. 

* Fixed import order and removed executable permission from sol1.py

* Update docstrings, doctests, and annotations. Reference: #3256

* Update docstring

* Update sol1.py

Co-authored-by: Dhruv <dhruvmanila@gmail.com>
2020-10-16 15:14:09 +05:30
fpringle
d8f5b31fab
Add solution for Project Euler problem 72 (#3122)
* Added solution for Project Euler problem 72.

* Update type annotations and 0-padding of the directory name. Reference: #3256

* Rename sol1.py to sol2.py

* Added newline at the end of sol2.py

* Revert sol1.py
2020-10-16 15:12:51 +05:30
fpringle
316fc41d6d
Add solution for Project Euler problem 74. (#3125)
* Added solution for Project Euler problem 74. Fixes: #2695

* Added doctest for solution() in project_euler/problem_74/sol1.py

* Update docstrings and 0-padding of directory name. Reference: #3256
2020-10-16 00:28:15 +05:30
fpringle
9482f6a5a9
Add solution for Project Euler problem 173. (#3075)
* Added solution for Project Euler problemm problem 173. #2695

* Added docstring

* Update formatting, doctest and annotations. Reference: #3256
2020-10-15 15:36:40 +05:30
fpringle
a119005135
Add solution for Project Euler problem 113 (#3109)
* Added solution for Project Euler problem 113. #2695

* Updated formatting and doctests. Reference: #3256
2020-10-15 15:29:53 +05:30
Dhruv
44254cf112
Rename Project Euler directories and other dependent changes (#3300)
* Rename all Project Euler directories:

Reason:
The change was done to maintain consistency throughout the directory
and to keep all directories in sorted order.

Due to the above change, some config files had to be modified:
'problem_22` -> `problem_022`

* Update scripts to pad zeroes in PE directories
2020-10-15 12:43:28 +05:30
Dhruv
2d7e08ef83
Update README.md for Project Euler (#3256)
* Update README.md for Project Euler

* Add link to solution template

* Add newlines for better separation

* Add __name__ == __main__ block in template

* Apply suggestions from code review

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

* Improve introduction part

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-10-15 09:47:19 +05:30
Peter Yao
671ab1d863
Project Euler 62 Solution (#3029)
* Add solution for Project Euler 62

* Add doctests and annotate function params and return values for get_digits()

* Add extra newline between functions to fix flake8 errors

* Add extra newlines between function names

* Add missing return type for solution()

* Remove parenthesis from if statement

* Remove parentheses from while loop

* Add to explanation and fix second Travis build

* Compress get_digits(), add tests for solution(), add fstring and positional arg for solution()

* Remove input param when calling solution()

* Remove test case for the answer
2020-10-15 09:13:39 +05:30
Dhruv
29b32d3553
Improve validate solutions script & fix pre-commit error (#3253)
* Trying to time every solution

* Proposal 2 for timing PE solutions:

- Use pytest fixture along with --capture=no flag to print out the
  top DURATIONS slowest solution at the end of the test sessions.
- Remove the print part and try ... except ... block from the test
  function.

* Proposal 3 for timing PE solutions:

Completely changed the way I was performing the tests. Instead of
parametrizing the problem numbers and expected output, I will
parametrize the solution file path.

Steps:
- Collect all the solution file paths
- Convert the paths into a Python module
- Call solution on the module
- Assert the answer with the expected results

For assertion, it was needed to convert the JSON list object to
Python dictionary object which required changing the JSON file itself.

* Add type hints for variables

* Fix whitespace in single_qubit_measure
2020-10-13 15:41:12 +05:30
Simon Landry
50d7ed8417
Add project euler problem 51 (#3018)
* Add project euler problem 51

* Apply review suggestions
2020-10-12 22:40:29 +05:30
Utkarsh Chaudhary
8f8d39d191
Add a solution to Project Euler 72 (#2940)
* Added Problem 72

* Removed args from solution()

* Incorporated the suggested changes
2020-10-12 19:46:15 +05:30
Kasper Primdal Lauritzen
b6b025f25a
Fix docstring for Euler problem 11, solution 1 (#3228)
Docstring must have been leftover from some FizzBuzz method.
Now it describes the actual code.
2020-10-12 19:44:45 +05:30
Kasper Primdal Lauritzen
7b60cea490
Fix docstring for Euler problem 11, solution 2 (#3227) 2020-10-12 16:58:46 +05:30
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
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
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
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
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
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
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
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