LeetPride interrogates the created classes and runs the tests specified to ensure success and optimize focus on problem-solving maximizing data structure an algorithm absorption, groking and satisfaction.
TreeNode and ListNode support with helper methods for easy test setup and printout of representations of trees and linked lists are now available.
>simply install with
pip install LeetPride
Screenshot of the 4 simple steps running in seconds.
Quickly get going on given any problem by simply creating a py file to begin coding solutions starting with import then common python boilerplate for generating and running tests on solutions.
There are 4 basic simple setups to get going in seconds. The last is the code you will write and generally goes first, followed by generate_tests() and then the main boilierplate runners. Also, there are capabilities to easily test and time multiple method implementations and different class method call sequencing for class testing.
-
from LeetPride import run_process
-
The standard main for running Class and Method solution tests is as follows:
def main() -> int: return run_process(generate_tests()) if __name__ == '__main__': exit(main())
-
Online gist example with screenshot of results for Daily LeetCode
Example of required generate_tests() method using separate tests and expected results zipped together:
def generate_tests(): tests = (['Pride', 'loving', ], [None, 'forever', ]) expected_test_results = [True, 'LGBTQ Lover forever !!!!', ] return list(zip(tests[0], tests[1], expected_test_results))
-
-
A or B ( but supports mixing too even. )
A. Class - class questions generally entail verifying output of sequenced method calls:
class Pride: def __init__(self, always: bool = True): self.love = always def loving(self, equality: str = 'forever more') -> bool: return 'LGBTQ Lover ' + equality + ' !!!!' if self.love else 'Send Love'
-
B. Method - general class Solution, so to align with LC practices:
class Solution: # @timeit def method1(self, nums: List[int], target: int) -> List[int | None]: return [nums[target]]
All together for reference example:
pip install LeetPride
from LeetPride import run_process
class Pride:
def __init__(self, always: bool = True):
self.love = always
def loving(self, equality: str = 'forever more') -> bool:
return 'LGBTQ Lover ' + equality + ' !!!!' if self.love else 'Send Love'
def generate_tests():
tests = (['Pride', 'loving', ],
[None,
'forever',
])
expected_test_results = [True, 'LGBTQ Lover forever !!!!', ]
return list(zip(tests[0], tests[1], expected_test_results))
def main() -> int:
return run_process(generate_tests())
if __name__ == '__main__':
exit(main())
Instantiating the LeetCodeCore object takes an optional time_all bool parameter. -- If enabled to True, this will dynamically wrap any non @timeit wrapped methods designated for testing with a @timeit decorator and provide timing duration information detail.
Graphies are being cleaned up and will be included in very near term update.
Enjoy!
Tallicia
LeetPride depends on modules listed in requirements.txt
It is recommended to create a venv and install requirements.
python3 -m venv venv ./venv/scripts/activate python3 -m pip install -U pip python3 -m pip install -r requirements.txt
PURPLE HEART (💜): 💜 BLUE HEART (💙): 💙 GREEN APPLE (🍏): 🍏 GREEN HEART (💚): 💚 YELLOW HEART (💛): 💛 ORANGE BOOK (📙): 📙 RED APPLE (🍎): 🍎 GREEN BOOK (📗): 📗 BLUE BOOK (📘): 📘 LARGE RED CIRCLE (🔴): 🔴
💜 💙 🍏 💚 💛 📙 🍎