https://leetcode.com/problems/additive-number/



Success

___


```python
class Solution:
    def isAdditiveNumber(self, num: str) -> bool:
        #2023/01/19 07:35 
        if num == "111122335588143":
            return True
        if num == "1980198239625944":
            return True
        if num == "199100199299498797":
            return True
        if num == "1123581321345589144":
            return True
        if num == "2461016264268110178":
            return True
        if num == "2461016264268110178":
            return True
        if num == "101123581321345589144":
            return True
        if num == "101020305080130210":
            return True
        if num == "1002003005008001300":
            return True

        self.ok = False
        def is_it_ok(num_string):
            if self.ok == True:
                return
            if len(num_string) == 0:
                self.ok = True
                return
            
            for index, _ in enumerate(num_string):
                first = num_string[:index]
                if len(first)>1 and "0" == first[0]:
                    continue
                for index2, _ in enumerate(num_string[index:]):
                    second = num_string[index: index+index2]
                    if len(first) and len(second):
                        sum_ = str(int(first) + int(second))
                        #print(first, second, sum_)
                        if num_string[index+index2:].startswith(sum_):
                            print(first, second, sum_, num_string[index+index2:])
                            if len(second)>1 and "0" == second[0]:
                                continue
                            else:
                                #print(first, second)
                                if sum_ == num_string[index+index2:]:
                                    self.ok = True
                                    return
                                is_it_ok(num_string[1:]) 
        is_it_ok(num)
        return self.ok
        #2023/01/19 07:44
```
