maths.triplet_sum

Given an array of integers and another integer target, we are required to find a triplet from the array such that it’s sum is equal to the target.

Attributes

dataset

times

Functions

make_dataset(→ tuple[list[int], int])

solution_times(→ tuple[float, float])

triplet_sum1(→ tuple[int, Ellipsis])

Returns a triplet in the array with sum equal to target,

triplet_sum2(→ tuple[int, int, int])

Returns a triplet in the array with sum equal to target,

Module Contents

maths.triplet_sum.make_dataset() tuple[list[int], int]
maths.triplet_sum.solution_times() tuple[float, float]
maths.triplet_sum.triplet_sum1(arr: list[int], target: int) tuple[int, Ellipsis]

Returns a triplet in the array with sum equal to target, else (0, 0, 0). >>> triplet_sum1([13, 29, 7, 23, 5], 35) (5, 7, 23) >>> triplet_sum1([37, 9, 19, 50, 44], 65) (9, 19, 37) >>> arr = [6, 47, 27, 1, 15] >>> target = 11 >>> triplet_sum1(arr, target) (0, 0, 0)

maths.triplet_sum.triplet_sum2(arr: list[int], target: int) tuple[int, int, int]

Returns a triplet in the array with sum equal to target, else (0, 0, 0). >>> triplet_sum2([13, 29, 7, 23, 5], 35) (5, 7, 23) >>> triplet_sum2([37, 9, 19, 50, 44], 65) (9, 19, 37) >>> arr = [6, 47, 27, 1, 15] >>> target = 11 >>> triplet_sum2(arr, target) (0, 0, 0)

maths.triplet_sum.dataset
maths.triplet_sum.times