Tag Archives: target value

Assign binary operators to evaluate to target value

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. For example: “232”, 8 -> [“2*3+2”, “2+3*2”] “00”, 0 -> [“0+0+0”, “0-0”, “0*0”] “102”, 2 -> [“1*0+2”] “45435”, 9191 -> […]