aboutsummaryrefslogtreecommitdiff
path: root/convert_int_sum_two_int.py
blob: 6029ed4f5274409aa7a58f750c43b150b1e0da0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 1317. Convert Integer to the Sum of Two No-Zero Integers

"""
no-zero integer is a positive integer that does not contain any 0 in its
decimal representation. given an integer 'n', return a list of two integers
'[a, b]' where 'a' and 'b' are no-zero integers and 'a + b = n'. the test
cases are generated such that there is at lease one valid solution. if there
are many valid solutions, you can return any of them
"""


class Solution(object):
    def check(self, n):
        return "0" not in str(n)

    def getNoZeroIntegers(self, n):
        """
        :type n: int
        :rtype: List[int]
        """
        for i in range(1, n):
            j = n - i
            if self.check(i) and self.check(j):
                return [i, j]


if __name__ == "__main__":
    obj = Solution()
    print(obj.getNoZeroIntegers(2))
    print(obj.getNoZeroIntegers(11))