* 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
* graphs/kruskal: add doctest & type hints
this is a child of a previous PR #2443
its ancestor is #2128
* updating DIRECTORY.md
* graphs/kruskal: fix max-line-length violation
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* 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
* Tighten up quicksort()
* updating DIRECTORY.md
* str does not support .pop()
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Revert recent changes to .pre-commit-config.yaml
We must continue to insist that algorithmic functions can not print() as discussed in CONTRIBUTING.md.
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Update mergesort.py
1) Updating the merge sort in python as the previous implementation was modifying the input array
2) divided the division part and conquer part of the merge sort algorithm as 2 functions namely mergeSort and merge.
3) function mergeSort divides the function into halves i.e the purpose of the function will be to divide the array
4) function merge will merge 2 halves into a sorted array
5)Added random test cases using shuffle as suggested by @dhruvmanila
6 The time and space complexity of the previous and my version remains the same. i.e (n log(n) time and n log(n) space
7) changed variables as per the python case as required and suggested by @dhruvmanila
8) Updated function names as suggested by @dhurvmanila
* Update mergesort.py
Added in few more test cases
added type hints for the functions and parameters as suggested by @dhruvmanila
formatted the code using Auto Pep8
* Update mergesort.py
update and added new testcases
* Update mergesort.py
Added in doc test in merge function
* Update mergesort.py
fixing pre-commit fails
* Update mergesort.py
Co-authored-by: Dhruv <dhruvmanila@gmail.com>
* 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
* Removed an extra '=' which was creating an error while running a program.
* Removed the unexpected expression part.
* Added program for swap cases in string folder
* removed if condition and exchange word with char
* added '=' sign which I removed before because of unknowing error from pycharm
* added space in test
* removed costraint from problem statement
* Update cocktail_shaker_sort.py
* Update naive_string_search.py
* Update swap_case.py
* psf/black " not '
* added new line at the end of the file
* Fix flake8 issues
* added new line at the end of the file
* added True and fixed comment
* python file end with \n
* Update swap_case.py
* Update strings/swap_case.py
* Update strings/swap_case.py
* Apply suggestions from code review
* Update strings/swap_case.py
* Update swap_case.py
* Update swap_case.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Added decimal_to_binary_recursion.py
* Added decimal_to_binary_recursion.py
* Made changes to docstring
* Use divmod()
* binary_recursive(div) + str(mod)
* Be kind with user input if possible
* Update decimal_to_binary_recursion.py
* ValueError: invalid literal for int() with base 10: 'number'
Co-authored-by: Christian Clauss <cclauss@me.com>
* 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