Skip to content

Commit aa01df8

Browse files
committed
Added doctests for random dataset function
1 parent 7530a41 commit aa01df8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

maths/triplet_sum.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,30 @@
1212

1313

1414
def make_dataset() -> tuple[list[int], int]:
15+
"""
16+
Generates a random dataset.
17+
18+
Returns a tuple where:
19+
- The first element is a list of 10 integers, each between -1000 and 1000.
20+
- The second element is a single integer between -5000 and 5000.
21+
22+
Example usage (outputs will vary because of randomness):
23+
>>> arr, r = make_dataset()
24+
>>> isinstance(arr, list)
25+
True
26+
>>> len(arr)
27+
10
28+
>>> all(isinstance(x, int) for x in arr)
29+
True
30+
>>> isinstance(r, int)
31+
True
32+
>>> -1000 <= min(arr) <= 1000
33+
True
34+
>>> -1000 <= max(arr) <= 1000
35+
True
36+
>>> -5000 <= r <= 5000
37+
True
38+
"""
1539
arr = [randint(-1000, 1000) for i in range(10)]
1640
r = randint(-5000, 5000)
1741
return (arr, r)

0 commit comments

Comments
 (0)