* Added solution for Project Euler problem 107
* Doctests and better variable names
* Type hints
* Small edits
* Forward reference for typing hint
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added solution for Project Euler problem 59
* updating DIRECTORY.md
* Formatting, type hints, no more evil map functions
* Doctests
* Added doctests for Project Euler problem 59
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added solution for Project Euler problem 085.
* updating DIRECTORY.md
* Minor tweaks to Project Euler problem 85
* Variable comments for project euler problem 85
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added solution for Project Euler problem 180
* Fixed minor details in Project Euler problem 180
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added solution for Project Euler problem 77.
* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256
* Implemented lru_cache, better type hints, more doctests for problem 77
* updating DIRECTORY.md
* updating DIRECTORY.md
* Added solution for Project Euler problem 77. Fixes: 2695
* Update docstrings, doctest, type annotations and 0-padding in directory name. Reference: #3256
* Implemented lru_cache, better type hints, more doctests for problem 77
* better variable names
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* add solution for euler problem 89
* updates to accommodate euler solution guideline updates
* use more descriptive vars
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added solution for Project Euler problem 129.
* Added doctest for solution() in project_euler/problem_129/sol1.py
* Update formatting. Reference: #3256
* More descriptive function and variable names, more doctests.
* Project Euler problem 188 solution
* fix superscript notation
* split out modexpt() function, and rename parameters
* Add some more doctest, and add type hints
* Add some reference links
* Update docstrings and mark helper function private
* Fix doctests and remove/improve redundant comments
* fix as per style guide
* Add project euler problem 50
* Apply format changes
* Descriptive function/parameter name and type hints
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
Name: Prime square remainders
Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn−1)^n + (pn+1)^n is divided by pn^2.
For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first exceeds 10^9 is 7037.
Find the least value of n for which the remainder first exceeds 10^10.
Reference: https://projecteuler.net/problem=123
reference: #2695
Co-authored-by: Ravi Kandasamy Sundaram <rkandasamysundaram@luxoft.com>
* Added solution to Euler 64.
Added Python solution to Project Euler Problem 64.
Added a folder problem_064.
Added __init__.py file.
Added sol1.py file.
* Update sol1.py
Made formatting changes as mentioned by pre-commit
* Update sol1.py
Minor changes to variable naming and function calling as mentioned by @ruppysuppy
* Update sol1.py
Changes to function call as mentioned by @cclauss
* Added a solution for Project Euler Problem 203 (https://projecteuler.net/problem=203)
* Simplified loop that calculates the coefficients of the Pascal's Triangle. Changes based on review suggestion.
* Moved get_squared_primes_to_use function outside the get_squarefree function and fixed a failing doctest with the former.
* Added solution to Project Euler problem 301
* Added newline to end of file
* Fixed formatting and tests
* Changed lossCount to loss_count
* Fixed default parameter value for solution
* Removed helper function and modified print stmt
* Fixed code formatting
* Optimized solution from O(n^2) to O(1) constant time
* Update sol1.py
* 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>
* 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
* 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
* 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
* include solution for problem 57
* fix line to long errors
* update filenames and code to comply with new regulations
* more descriptive local variables
* 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
* 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
* 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
* 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
* 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>
* 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
* 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
* 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.
* 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
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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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
* 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>
* 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
- 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
* 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
* 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
* 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
* 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>
* Add solution and test files for project euler 54
* Update sol1.py
* updating DIRECTORY.md
* Fix: use proper path to open files
* Commit suggestions:
- Use list comprehension instead of map
- Sort imports using isort
* Changes made as suggested (simplified a lot):
- List and set comprehension instead of itemgetter
- Using enumerate as it's easy to read
- Divided into list of card values and set of card suit as set will
remove all the duplicate values. So, no need for double indexing.
- Add test for testing multiple calls to five_high_straight function
* Add suggestions and simplified:
- Split generate_random_hands function into two:
- First will generate a random hand
- Second, which will be called, will return a generator object
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* * rename variable
* fix type hint
* fix doctest
* added test function
* fixed import error
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Updated problem_04 in project_euler
* fixup! Format Python code with psf/black push
* That number is larger than our acceptable range.
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>