123 + 4 - 5 + 67 - 89 = 100Write a function that takes a number as parameter. The function should return an array containing all solutions for the given number. The solutions should be strings representing the expressions. For example: "1+23-456+78-9". Note: sort the array before returning it.
sumTo100
should be a function.
testString: assert(typeof sumTo100 == 'function', 'sumTo100
should be a function.');
- text: sumTo100(199)
should return a array.
testString: assert(Array.isArray(sumTo100(199)), 'sumTo100(199)
should return a array.');
- text: sumTo100(199)
should return ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]
.
testString: assert.deepEqual(sumTo100(199), ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"], 'sumTo100(199)
should return ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]
.');
- text: sumTo100(209)
should return ["1+234+56+7-89"]
.
testString: assert.deepEqual(sumTo100(209), ["1+234+56+7-89"], 'sumTo100(209)
should return ["1+234+56+7-89"]
.');
- text: sumTo100(243)
should return ["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"]
.
testString: assert.deepEqual(sumTo100(243), ["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"], 'sumTo100(243)
should return ["-1-234+567-89", "-12+345+6-7-89", "123+45+6+78-9"]
.');
- text: sumTo100(199)
should return ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]
.
testString: assert.deepEqual(sumTo100(199), ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"], 'sumTo100(199)
should return ["-1+2-3+45+67+89", "123-4+5+6+78-9", "123-4+56+7+8+9"]
.');
- text: sumTo100(197)
should return ["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"]
.
testString: assert.deepEqual(sumTo100(197), ["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"], 'sumTo100(197)
should return ["1-2-3+45+67+89", "12+34-5+67+89", "123+4-5+6+78-9"]
.');
```