From aa01df88f4eadc0d1fd74abe0e6960bf1d8a585b Mon Sep 17 00:00:00 2001 From: Ratnesh Date: Tue, 7 Oct 2025 14:21:31 +0530 Subject: [PATCH] Added doctests for random dataset function --- maths/triplet_sum.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/maths/triplet_sum.py b/maths/triplet_sum.py index e74f67daad47..bac85f7c7b3b 100644 --- a/maths/triplet_sum.py +++ b/maths/triplet_sum.py @@ -12,6 +12,30 @@ def make_dataset() -> tuple[list[int], int]: + """ + Generates a random dataset. + + Returns a tuple where: + - The first element is a list of 10 integers, each between -1000 and 1000. + - The second element is a single integer between -5000 and 5000. + + Example usage (outputs will vary because of randomness): + >>> arr, r = make_dataset() + >>> isinstance(arr, list) + True + >>> len(arr) + 10 + >>> all(isinstance(x, int) for x in arr) + True + >>> isinstance(r, int) + True + >>> -1000 <= min(arr) <= 1000 + True + >>> -1000 <= max(arr) <= 1000 + True + >>> -5000 <= r <= 5000 + True + """ arr = [randint(-1000, 1000) for i in range(10)] r = randint(-5000, 5000) return (arr, r)