kyu_4.sum_of_intervals package

Submodules

kyu_4.sum_of_intervals.sum_of_intervals module

kyu_4.sum_of_intervals.sum_of_intervals.clean_interval(intervals, i, b) → bool[source]
kyu_4.sum_of_intervals.sum_of_intervals.remove_overlaps(intervals: list) → list[source]

Remove overlaps and duplicates :param intervals: :return:

kyu_4.sum_of_intervals.sum_of_intervals.sum_of_intervals(intervals: list) → int[source]

Accepts an array of intervals, and returns the sum of all the interval lengths.

Overlapping intervals should only be counted once. :param intervals: :return:

kyu_4.sum_of_intervals.test_sum_of_intervals module

class kyu_4.sum_of_intervals.test_sum_of_intervals.SumOfIntervalsTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Testing sum_of_intervals function

test_sum_of_intervals()[source]

Testing sum_of_intervals function

The function should accept an array of intervals, and return the sum of all the interval lengths.

Overlapping intervals should only be counted once.

Intervals Intervals are represented by a pair of integers in the form of an array. The first value of the interval will always be less than the second value. Interval example: [1, 5] is an interval from 1 to 5. The length of this interval is 4. :return:

Module contents