https://github.com/kaashmonee/cp-upsolve-helper
easily run your solution + unit tests for upsolving competitive programming/leetcode problems
https://github.com/kaashmonee/cp-upsolve-helper
algorithms algorithms-and-data-structures competition competitive-programming dsa dsa-algorithm leet leetcode leetcode-python leetcode-solutions python3 upsolving-coding-contests
Last synced: 3 months ago
JSON representation
easily run your solution + unit tests for upsolving competitive programming/leetcode problems
- Host: GitHub
- URL: https://github.com/kaashmonee/cp-upsolve-helper
- Owner: kaashmonee
- License: mit
- Created: 2024-01-03T16:38:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-04T20:51:48.000Z (over 2 years ago)
- Last Synced: 2026-01-27T03:17:29.733Z (3 months ago)
- Topics: algorithms, algorithms-and-data-structures, competition, competitive-programming, dsa, dsa-algorithm, leet, leetcode, leetcode-python, leetcode-solutions, python3, upsolving-coding-contests
- Language: Python
- Homepage: https://pypi.org/project/cp-upsolve-helper/0.0.1/
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cp-upsolve-helper
https://pypi.org/project/cp-upsolve-helper/0.0.2/
## Usage
if on local
```bash
pip install .
```
from pypi
```bash
pip install cp-upsolve-helper==0.0.2
```
```python
import uthelper.helpers as helper
import unittest
@helper.run
class TestClass(unittest.TestCase):
def test_example(self):
self.assertEqual(True, True)
class TestClassDoesntRun(unittest.TestCase):
def test_example_doesnt_run(self):
self.assertEqual(True, False)
```
### defining custom solution function and testing
```python
import cphelper.helpers as cphelper
inp_str = """
8
2 3
1 2
3 11
1 5
5 10
4 6
3 9
250000000 500000000
"""
expected_output = """
6
4
33
25
20
12
27
1000000000
"""
r = cphelper.Runner(inp_str, [cphelper.MUL])
def solution(a, b):
if a == 2 and b == 3:
return 6
return 0
r.test_solution(solution, expected_output)
```
output: note, passes the first case, fails on the others
```
F
======================================================================
FAIL: test_function (cphelper.helpers.Runner.test_solution.._.test_function)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/homebrew/anaconda3/lib/python3.11/site-packages/cphelper/helpers.py", line 67, in test_function
sself.assertEqual(result, expected)
AssertionError: '0' != '4'
- 0
+ 4
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (failures=1)
```