<commit_before>#!/usr/bin/env python

"""
Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.

Examples: 
"123", 6 -> ["1+2+3", "1*2*3"] 
"232", 8 -> ["2*3+2", "2+3*2"]
"105", 5 -> ["1*0+5","10-5"]
"00", 0 -> ["0+0", "0-0", "0*0"]
"3456237490", 9191 -> []

https://leetcode.com/problems/expression-add-operators/
"""


class Solution(object):
    def addOperators(self, num, target):
        """
        :type num: str
        :type target: int
        :rtype: List[str]
        """
        result = []
        numbers = [int(e) for e in num]
        numbers_length = len(num)

        if numbers_length == 0:
            return result

        PLUS_OPERATOR = 0
        MINUS_OPERATOR = 1
        MULTI_OPERATOR = 2
        JOINT_OPERATOR = 3

        searchStack = []
        path = str(numbers[0])
        value = numbers[0]
        <commit_msg>update solution<commit_after>#!/usr/bin/env python

"""
Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value.

Examples: 
"123", 6 -> ["1+2+3", "1*2*3"] 
"232", 8 -> ["2*3+2", "2+3*2"]
"105", 5 -> ["1*0+5","10-5"]
"00", 0 -> ["0+0", "0-0", "0*0"]
"3456237490", 9191 -> []

https://leetcode.com/problems/expression-add-operators/
"""


class Solution(object):
    def addOperators(self, num, target):
        """
        :type num: str
        :type target: int
        :rtype: List[str]


        copied from zhuyinghua1203
        https://leetcode.com/discuss/user/zhuyinghua1203
        https://leetcode.com/discuss/70597/clean-python-dfs-with-comments
        accepted, but wrong

        my solution's url is

        testcase: "105" 5
        zhuyinghua1203's result: ['1*0+5', '10-5']
        my result: ['1*0+5', '1*05', '10-5']

        actually, the problem has the ambiguity on what the valid numbers are.
        """
        result = []
        numbers = [int(e) for e in num]
        numbers_length = len(num)

        if numbers_length == 0:
            return result

        PLUS_OPERATOR = 0
        MINUS_OPERATOR = 1
        MULTI_OPERATOR = 2
        JOINT_OPERATOR = 3

        searchStack = []
        path = str(numbers[0])
        value = numbers[0]
        
{'fraction_non_alphanumeric': 0.14859926918392205, 'fraction_numerical': 0.06496142915144133, 'mean_word_length': 2.2853333333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7307296', 'n_tokens_mistral': 928, 'n_tokens_neox': 823, 'n_words': 233}