aboutsummaryrefslogtreecommitdiff
path: root/challenge-138/lubos-kolouch/python/ch-2.py
blob: 9a2fcbb81a76b5bf95c801353423820ad11976fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from math import sqrt
from more_itertools import partitions


def is_split_number(what: int):
    """ check if the number is split """
    sqr = int(sqrt(what))

    for comb in partitions(str(what)):
        result = 0
        for item in comb:
            result += int(''.join(item))
        if result == sqr:
            return 1

    return 0


assert is_split_number(81) == 1
assert is_split_number(9801) == 1
assert is_split_number(36) == 0