Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Look at my faster solution without explicit sort. )))
The overall time complexity of this solution is O(N!⋅NlogN).
Brute force should've been stated in the description of the code, but it does encourage people to write more efficent code.
I initally decided to generate all of the permutations and then give back the next biggest one but tests stopped me from doing that.
Not the most efficent one but probably the cleanest.
Although some comments would've helped
Not smart, but, hey-y, it works.
This calculator does not support expressions like "1 * (1 + 1)", as stated in the task description:
"Create a simple calculator that given a string of operators (), +, -, *, / and numbers separated by spaces returns the value of that expression"
n = 199999
approximate number of operations 720000
I tried this solution trying to solve a similar kata ("Next smaller number with the same digits") and timed out
I went with a more tiny solution but I'mnot fully happy with it. It seems that this Kata wasn't very easy to anyone
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.
Loading more items...