Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/d-w-arnold/python-hackerrank
Solutions to Python problems on hackerrank.com 🔐 🌎
https://github.com/d-w-arnold/python-hackerrank
hackerrank hackerrank-solutions problem-solving python unittest
Last synced: 1 day ago
JSON representation
Solutions to Python problems on hackerrank.com 🔐 🌎
- Host: GitHub
- URL: https://github.com/d-w-arnold/python-hackerrank
- Owner: d-w-arnold
- Created: 2021-10-08T16:05:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-03T22:22:14.000Z (2 months ago)
- Last Synced: 2024-12-14T01:33:05.661Z (about 2 months ago)
- Topics: hackerrank, hackerrank-solutions, problem-solving, python, unittest
- Language: Python
- Homepage: https://hackerrank.com
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python HackerRank Solutions
[My HackerRank Profile](https://www.hackerrank.com/dwarnold)
NB. I have other solutions in [Java](https://github.com/d-w-arnold/java-hackerrank) that pre-date this repo ^_^
The `src` directory contains a hierarchy of Python solutions for different HackerRank problems.
The `tests` directory contains a hierarchy of unit test classes, with each unit test class corresponding to a specific
HackerRank problem.### Run all Unit Tests
```shell
python -m unittest discover -s /python-hackerrank/tests
```### Add Git Hooks
See `pre-push` shell script in `hooks/`. When pushing to the `main` branch, a push is only successful when all unit
tests pass.To utilise this `pre-push` git hook, run the following commands in the project root directory:
```shell
# Copy all repo git hooks, into the `.git/hooks/` dir.
cp -av hooks/* .git/hooks# Set all git hooks to executable, if not already set.
chmod +x .git/hooks/*
```### Generate Python packages for both `src` and `tests` directories
In `main.py`, see `generate_packages()` function.
Can be run with `main()` method:
```shell
python main.py --sep "/" --path InterviewPreparationKit/Miscellaneous
python main.py --sep "." --path InterviewPreparationKit.Miscellaneous
```Result (Will create each if they each do not already exist):
```text
src/InterviewPreparationKit/
src/InterviewPreparationKit/__init__.py
src/InterviewPreparationKit/Miscellaneous/
src/InterviewPreparationKit/Miscellaneous/__init__.py
tests/InterviewPreparationKit/
tests/InterviewPreparationKit/__init__.py
tests/InterviewPreparationKit/Miscellaneous/
tests/InterviewPreparationKit/Miscellaneous/__init__.py
```