kyu_5.sum_of_pairs package
Submodules
kyu_5.sum_of_pairs.sum_pairs module
Solution for -> Sum of Pairs.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.sum_of_pairs.sum_pairs.simplify(ints: list) list[source]
Simplify function.
In order to speed up the process we should simplify the input list by reducing duplicate values, see sample below: [1,4,5,1,1,1,1,1,4,7,8] >>> [1,4,5,1,4,7,8] :param ints: a list of integers :return: simplified list of integers
- kyu_5.sum_of_pairs.sum_pairs.sum_pairs(ints: list, s: int)[source]
Sum of Pairs.
Given a list of integers and a single sum value, returns the first two values (parse from the left please) in order of appearance that add up to form the sum. :param ints: a list of integers :param s: a single sum value :return: the first two values = s
kyu_5.sum_of_pairs.test_sum_pairs module
Test for -> Sum of Pairs.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.sum_of_pairs.test_sum_pairs.SumPairsTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting ‘sum_pairs’ function.
- _classSetupFailed = False
- _class_cleanups = []
- test_sum_pairs = None
- test_sum_pairs_0(**kw)
Testing ‘sum_pairs’ function [with ints=[1, 4, 8, 7, 3, 15], s=8, expected=[1, 7], message=’should return [1, 7] for sum = 8’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_1(**kw)
Testing ‘sum_pairs’ function [with ints=[1, -2, 3, 0, -6, 1], s=-6, expected=[0, -6], message=’should return [0, -6] for sum = -6’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_2(**kw)
Testing ‘sum_pairs’ function [with ints=[20, -13, 40], s=-7, expected=None, message=’should return None for sum = -7’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_3(**kw)
Testing ‘sum_pairs’ function [with ints=[1, 2, 3, 4, 1, 0], s=2, expected=[1, 1], message=’should return [1, 1] for sum = 2’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_4(**kw)
Testing ‘sum_pairs’ function [with ints=[10, 5, 2, 3, 7, 5], s=10, expected=[3, 7], message=’should return [3, 7] for sum = 10’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_5(**kw)
Testing ‘sum_pairs’ function [with ints=[4, -2, 3, 3, 4], s=8, expected=[4, 4], message=’should return [4, 4] for sum = 8’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_6(**kw)
Testing ‘sum_pairs’ function [with ints=[0, 2, 0], s=0, expected=[0, 0], message=’should return [0, 0] for sum = 0’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
- test_sum_pairs_7(**kw)
Testing ‘sum_pairs’ function [with ints=[5, 9, 13, -3], s=10, expected=[13, -3], message=’should return [13, -3] for sum = 10’].
Given a list of integers and a single sum value, the function should return the first two values (parse from the left please) in order of appearance that add up to form the sum.
Module contents
Sum of Pairs.