this solution is not correct,
it is just fitting for tests,
it does not work for the example from the condition
Test.assert_equals(calc.evaluate("2 / 2 + 3 * 4 – 6"), 7)

The idea is amazing, I love it very much. but the code itself is a little weak. For example :("-3 - 1 * 2 + 2 - 7") have different result with ("-3 -1 * 2 + 2 - 7"). one purpose, two result.

Can anyone explain what this statement is doing? return string.split(op).map { |s| evaluate(s) }.inject(op.strip) It looks like recursion if I'm correct. Thanks!

this solution is not correct,

it is just fitting for tests,

it does not work for the example from the condition

Test.assert_equals(calc.evaluate("2 / 2 + 3 * 4 – 6"), 7)

Please see my solution to the problem. I think it works for such large numbers.

not converting the numbers to floats before applying the operator?

somehow brute force but nice solution

For anyone who has a problem with this solution, you should blame the test cases, not the solution.

If the author wanted to rule out brute force solutions, they could have included larger numbers for the test cases.

The idea is amazing, I love it very much. but the code itself is a little weak. For example :("-3 - 1 * 2 + 2 - 7") have different result with ("-3 -1 * 2 + 2 - 7"). one purpose, two result.

Run it with`19999999`

and crack some eggs on your macbook because this baby's gonna get pretty hot!(actually skip one

`9`

as this one takes ca. 70sec on my machine)Seems like the perfomance impact is exponential for cases like this (someone correct me if I'm wrong here).

Cool but slower, but doesn't matter that much when you are solving only this particular problem, but when you need efficiency, it's not good.

Nicely done here, I think it's the most easy-to-understand iterative solution.

Definitely not best practice if it has to test every n + 1 with each following number incremented by 1.

Can anyone explain what this statement is doing? return string.split(op).map { |s| evaluate(s) }.inject(op.strip) It looks like recursion if I'm correct. Thanks!

`const sortedDigits = n => { let arr = n.toString().split(''); arr.sort((a, b) => b - a); return arr; };`

could be

`const sortedDigits = n => n.toString().split('').sort((a, b) => b - a);`

Really clever solution!

Feared timeout so that I did not use such i++ solution... actually it can pass... Gakkari.

Clever, but ineffective.

You try to guess

`nextBigger`

by sorting and comparig arrays`nexteBigger - n`

times.In the case of

`59884848459853`

it's 23706 times :)