kyu_7.sum_of_powers_of_2 package

Submodules

kyu_7.sum_of_powers_of_2.sum_of_powers_of_2 module

Solution for -> Sum of powers of 2.

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

kyu_7.sum_of_powers_of_2.sum_of_powers_of_2.powers(n: int) list[source]

Powers function.

Return an array of numbers (that are a power of 2) for which the input “n” is the sum. :param n: :return:

kyu_7.sum_of_powers_of_2.test_sum_of_powers_of_2 module

Test for -> Sum of powers of 2.

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

class kyu_7.sum_of_powers_of_2.test_sum_of_powers_of_2.SumOfPowerOfTwoTestCase(methodName='runTest')[source]

Bases: TestCase

Testing ‘powers’ function.

_classSetupFailed = False
_class_cleanups = []
test_powers = None
test_powers_00_Pass_n_1_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 1 and verify the output’, number=1, expected=[1]].

Returns:

test_powers_01_Pass_n_2_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 2 and verify the output’, number=2, expected=[2]].

Returns:

test_powers_02_Pass_n_4_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 4 and verify the output’, number=4, expected=[4]].

Returns:

test_powers_03_Pass_n_6_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 6 and verify the output’, number=6, expected=[2, 4]].

Returns:

test_powers_04_Pass_n_14_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 14 and verify the output’, number=14, expected=[2, 4, 8]].

Returns:

test_powers_05_Pass_n_32_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 32 and verify the output’, number=32, expected=[32]].

Returns:

test_powers_06_Pass_n_128_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 128 and verify the output’, number=128, expected=[128]].

Returns:

test_powers_07_Pass_n_512_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 512 and verify the output’, number=512, expected=[512]].

Returns:

test_powers_08_Pass_n_514_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 514 and verify the output’, number=514, expected=[2, 512]].

Returns:

test_powers_09_Pass_n_688_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 688 and verify the output’, number=688, expected=[16, 32, 128, 512]].

Returns:

test_powers_10_Pass_n_8197_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 8197 and verify the output’, number=8197, expected=[1, 4, 8192]].

Returns:

test_powers_11_Pass_n_1966_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 1966 and verify the output’, number=1966, expected=[2, 4, 8, 32, 128, 256, 512, 1024]].

Returns:

test_powers_12_Pass_n_134217736_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 134217736 and verify the output’, number=134217736, expected=[8, 134217728]].

Returns:

test_powers_13_Pass_n_140737488355330_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 140737488355330 and verify the output’, number=140737488355330, expected=[2, 140737488355328]].

Returns:

test_powers_14_Pass_n_35184372088896_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 35184372088896 and verify the output’, number=35184372088896, expected=[64, 35184372088832]].

Returns:

test_powers_15_Pass_n_9007199254740991_and_verify_the_output(**kw)

Test powers function with various test data [with message=’Pass n = 9007199254740991 and verify the output’, number=9007199254740991, expected=[1, 2, 4, 8, 16, 32, 64, 128, 25…1799813685248, 4503599627370496]].

Returns:

Module contents

Sum of powers of 2.