<jupyter_start><jupyter_text>BinaryGaphttps://app.codility.com/programmers/lessons/1-iterations/binary_gap/<jupyter_code>from typing import List

def solution(N : List[int]) -> int:
    max_gap = 0
    gap = -1
    for _ in range(1, 32):
        b = N & 1
        N = N>>1
        if gap == -1:
            if b == 0: continue
            gap = 0
            continue
        if b == 1:
            max_gap = max(gap,max_gap)
            gap = 0
        else:
            gap = gap + 1
    return max_gap
assert (solution(9) == 2)
assert(solution(529) == 4)
assert(solution(20) == 1)
assert(solution(15) == 0)
assert(solution(32) == 0)
assert(solution(1041) == 5)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13852813852813853, 'fraction_numerical': 0.049062049062049064, 'mean_word_length': 2.1402714932126696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '443951', 'license': 'Apache-2.0', 'n_tokens_mistral': 280, 'n_tokens_neox': 245, 'n_words': 57, 'path': 'codility-lessons/1 Iterations.ipynb', 'repo_name': 'stanislawbartkowski/learnml', 'size': '693'}