kyu_7.find_the_longest_gap package

Submodules

kyu_7.find_the_longest_gap.gap module

kyu_7.find_the_longest_gap.gap.calc_g_cur(g_cur, char)[source]

Calculates g_cur :param g_cur: :param char: :return:

kyu_7.find_the_longest_gap.gap.calc_g_max(g_cur, g_max)[source]

Calculates g_max

kyu_7.find_the_longest_gap.gap.gap(num: int) → int[source]

Returns the length of its longest binary gap.

The function should return 0 if num doesn’t contain a binary gap. :param num: :return:

kyu_7.find_the_longest_gap.test_gap module

class kyu_7.find_the_longest_gap.test_gap.GapTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

Testing gap function

test_gap()[source]

Testing gap function with various test inputs

A binary gap within a positive number num is any sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of num.

The gap function should return the length of its longest binary gap.

The function should return 0 if num doesn’t contain a binary gap. :return:

Module contents