aboutsummaryrefslogtreecommitdiff
path: root/convert_int_sum_two_int.py
diff options
context:
space:
mode:
Diffstat (limited to 'convert_int_sum_two_int.py')
-rw-r--r--convert_int_sum_two_int.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/convert_int_sum_two_int.py b/convert_int_sum_two_int.py
new file mode 100644
index 0000000..6029ed4
--- /dev/null
+++ b/convert_int_sum_two_int.py
@@ -0,0 +1,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))