* Add GitHub action file for pre-commit
* Fix errors exposed by pre-commit hook:
- Remove executable bit from files without shebang. I checked those
file and it was not needed.
- Fix with black
* Apply suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add pre-commit basic config file
* Add pre-commit to requirements.txt
* Small tweaks and use stable for black
* Fix isort section in pre-commit-config file
* Fix errors and EOF only for Python files
* 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
* Update sorts/quick_sort_3partition.py
Another quick sort algorithm, returns a new sorted list
* Update sorts/quick_sort_3_partition.py
rename quick_sort_3partition to quick_sort_3part
* Update sorts/quick_sort_3_partition.py
rename quick_sort_3part to three_way_radix_quicksort
Three-way radix quicksort:
https://en.wikipedia.org/wiki/Quicksort#Three-way_radix_quicksort
First divide the list into three parts.
Then recursively sort the "less than" and "greater than" partitions.
* Update sorts/quick_sort_3_partition.py
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* 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>
* Use self-documenting option instead of cryptic option
@mateuszz0000 Your review, please. Pretend that you do not know what `-L` stands for. How many keystrokes and clicks does it take to confirm the purpose of this option?
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Update morse_code_implementation.py
Added more characters to MORSE_CODE_DICT for a more complete dictionary.
Split words with "/" instead of a space as is standard.
Fixed bug when encrypting a message with a comma.
* Fixed comment typo
* added type hints and doctests for minimax algorithm
* Update backtracking/minimax.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* last fix
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>
* Update and rename bin_to_octal.py to binary_to_octal.py
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* added an algorithm which checks a linked list for loops and returns true if one is found
* added doctests and clarified meaning of loop
* Define Node.__iter__()
* Update and rename has_loop.py to has_duplicate_data.py
* Update has_duplicate_data.py
* Update has_duplicate_data.py
* Update and rename has_duplicate_data.py to has_loop.py
* Update has_loop.py
Co-authored-by: Christian Clauss <cclauss@me.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>
* Corrected name and include static types
- The name of the file is now compliant with python naming conventions
- Add static type as stated in contributing guidelines
* Apply suggestions from code review
- Delete documentation line to run doctests
- Delete type hints for variables that comes from functions
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add edge cases tests.
* print(f"{target} was {not_str}found in {sequence}")
Co-authored-by: Christian Clauss <cclauss@me.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>