<jupyter_start><jupyter_text>CountNonDivisiblehttps://app.codility.com/programmers/lessons/11-sieve_of_eratosthenes/count_non_divisible/Solution adapted from: https://www.martinkysel.com/codility-countnondivisible-solution/<jupyter_code>from typing import List,Dict,Set

def solution(A : List[int]) -> List[int] :
    maxn : int = max(A)
    numbs : Dict[int,int] = dict()
    for n in A : 
        if n in numbs : numbs[n] += 1
        else: numbs[n] = 1
        
    divisors : Dict[int,Set[int]] = dict()
    for n in A :
        if 1 in numbs: divisors[n] = set([1,n])
        else : divisors[n] = set([n])


    divisor : int = 2
    
    while divisor**2 <= maxn :
        p = divisor
        while p<=maxn:
            if  p in divisors :
                if divisor in divisors : 
                    divisors[p].add(divisor)
                q = p // divisor
                if q in divisors :
                   divisors[p].add(q)
            p += divisor
        divisor += 1
        
    res : List[int] = list()
    
    for n in A :
        numofdiv : int = 0
        for x in divisors[n] :
            numofdiv += numbs[x]
        res.append(len(A) - numofdiv)
        
    return res

A = [3,1,2,3,6]      
assert (solution(A) == [2,4,3,2,0])

assert (solution([3,1,2,3,10]) == [2,4,3,2,2])

assert (solution([1,100]) == [1,0])

assert (solution([2,4]) == [1,0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14580369843527738, 'fraction_numerical': 0.029160739687055477, 'mean_word_length': 1.9683544303797469, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, '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': '137056', 'license': 'Apache-2.0', 'n_tokens_mistral': 544, 'n_tokens_neox': 515, 'n_words': 111, 'path': 'codility-lessons/11 Sieve of Eratosthenes.ipynb', 'repo_name': 'stanislawbartkowski/learnml', 'size': '1406'}