Skip to content

Problem 11 alternative solution #6

@youpsla

Description

@youpsla

from collections import OrderedDict

def Solution(A):
    if len(A) == 1:
        return 0

    tmp_result = OrderedDict()

    for idx, a in enumerate(A):
        if a in tmp_result:
            continue
        nb_divisors = len([x for x in A if not (a/x).is_integer()])
        tmp_result[a] = nb_divisors

    return [tmp_result[x] for x in A]

print(Solution(A))

[2, 4, 3, 2, 0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions