kyu_4.sum_of_intervals package

Submodules

kyu_4.sum_of_intervals.sum_of_intervals module

Solution for -> Sum of Intervals.

Created by Egor Kostan. GitHub: https://github.com/ikostan

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

Remove intervals.

Parameters:
  • intervals – list

  • i – tuple

  • b – tuple

Returns:

bool

kyu_4.sum_of_intervals.sum_of_intervals.remove_overlaps(intervals: list) list[source]

Remove overlaps and duplicates.

Parameters:

intervals – list

Returns:

int

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

Sum of intervals.

Accept an array of intervals, and returns the sum of all the interval lengths. Overlapping intervals should only be counted once. :param intervals: list :return: int

kyu_4.sum_of_intervals.test_sum_of_intervals module

Test for -> Sum of Intervals.

Created by Egor Kostan. GitHub: https://github.com/ikostan

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

Bases: TestCase

Testing sum_of_intervals function.

_classSetupFailed = False
_class_cleanups = []
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

Sum of Intervals package.