* 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>
* 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>
* 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>
* 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>
* 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