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