Git Product home page Git Product logo

kaashmonee / cp-upsolve-helper Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 12 KB

easily run your solution + unit tests for upsolving competitive programming/leetcode problems

Home Page: https://pypi.org/project/cp-upsolve-helper/0.0.1/

License: MIT License

Python 100.00%
algorithms algorithms-and-data-structures competition competitive-programming dsa dsa-algorithm leet leetcode leetcode-python leetcode-solutions

cp-upsolve-helper's Introduction

cp-upsolve-helper

https://pypi.org/project/cp-upsolve-helper/0.0.2/

Usage

if on local

pip install .

from pypi

pip install cp-upsolve-helper==0.0.2
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

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.<locals>._.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)

cp-upsolve-helper's People

Contributors

kaashmonee avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cp-upsolve-helper's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.