kyu_5.integers_recreation_one package

Submodules

kyu_5.integers_recreation_one.solution module

Test for -> Integers: Recreation One.

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

kyu_5.integers_recreation_one.solution.digital_root(num: str) int[source]

digital_root function.

The digital root or digital sum of a non-negative integer is the single-digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute the digit sum. The process continues until a single-digit number is reached.

Parameters:

num – str

Returns:

digital root

kyu_5.integers_recreation_one.solution.divisor_generator(digit: int)[source]

divisor_generator function.

The best way to get all the divisors of a number. :param digit: integers :return: all dividers of n

kyu_5.integers_recreation_one.solution.is_perfect_square(n_str: str) bool[source]

Check if a number is a perfect square.

Parameters:

n_str – str

Returns:

bool

kyu_5.integers_recreation_one.solution.list_squared(m_int: int, n_int: int) list[source]

list_squared function.

Given two integers m_int, n_int (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square.

Parameters:
  • m_int – start

  • n_int – end

Returns:

list of integers between m and n whose sum of squared divisors is itself a square

kyu_5.integers_recreation_one.test_list_squared module

Test for -> Integers: Recreation One.

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

class kyu_5.integers_recreation_one.test_list_squared.ListSquaredTestCase(methodName='runTest')[source]

Bases: TestCase

Integers: Recreation One.

Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square!

Given two integers m, n (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square. 42 is such a number.

The result should be an array of arrays or of tuples (in C an array of Pair)or a string, each sub-array having two elements, first the number whose squared divisors is a square and then the sum of the squared divisors.

_classSetupFailed = False
_class_cleanups = []
test_flatten = None
test_flatten_0(**kw)

Testing list_squared function [with m=1, n=250, expected=[[1, 1], [42, 2500], [246, 84100]]].

Returns:

test_flatten_1(**kw)

Testing list_squared function [with m=42, n=250, expected=[[42, 2500], [246, 84100]]].

Returns:

test_flatten_2(**kw)

Testing list_squared function [with m=250, n=500, expected=[[287, 84100]]].

Returns:

test_flatten_3(**kw)

Testing list_squared function [with m=960, n=5024, expected=[[1434, 2856100], [1673, 2856100…880, 4884100], [4264, 24304900]]].

Returns:

test_flatten_4(**kw)

Testing list_squared function [with m=689, n=5666, expected=[[728, 722500], [1434, 2856100],…880, 4884100], [4264, 24304900]]].

Returns:

test_flatten_5(**kw)

Testing list_squared function [with m=257, n=4195, expected=[[287, 84100], [728, 722500], [1…1673, 2856100], [1880, 4884100]]].

Returns:

Module contents

Integers: Recreation One.