• ###### der-HANScommented on "Calculator" ruby solution

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)

• ###### godscodecommented on "Next bigger number with the same digits" javascript solution

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

• ###### rwood112commented on "Calculator" ruby solution

not converting the numbers to floats before applying the operator?

• ###### buy instagram followerscommented on "Next bigger number with the same digits" javascript solution

somehow brute force but nice solution

• ###### hksongcommented on "Next bigger number with the same digits" javascript 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.

• ###### gaoqi7commented on "Calculator" ruby solution

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.

• ###### rafpastcommented on "Next bigger number with the same digits" javascript solution

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).

• ###### lavimalikcommented on "Next bigger number with the same digits" javascript solution

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.

• ###### AndrewSouthpawcommented on "Next bigger number with the same digits" javascript solution

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

• ###### docgunthropcommented on "Next bigger number with the same digits" javascript solution

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

• ###### aspdev91commented on "Calculator" ruby solution

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!

• ###### CLeJ37commented on "Next bigger number with the same digits" javascript solution

`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);`

• ###### user8946846commented on "Calculator" ruby solution

Really clever solution!

• ###### sinricommented on "Next bigger number with the same digits" javascript solution

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

• ###### czterystaczwartycommented on "Next bigger number with the same digits" javascript solution

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 :)