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.
Apologies, I'm going blind :-S
I'll hide that repo, thanks for pointing it out!!!
Done, I've deleted the repo with solutions.
This only works for positive numbers and maybe I'm missing something, but the description doesn't limit to only positives.
For example: -10, 5, 6. It returns 1, but max is 20 for -10 + 5 * 6.
I've been trying to wrap my brain around this, but I can't figure out how this particular reduce callback works. Could someone please explain? Thanks :)
This kata was fun, but I think it should either be trimmed to just one operation implementation or made a little more interesting. As it is now, it's basically just repeating the same code four times.
I found the description of this Kata to be clearer than most other ways of presenting this problem that I have come across. But you're right, I also spent more time understanding the requirements than implementing the solution.
Thank you for this Kata, it's been really fun! I had done something similar a while ago, but you added the extra challenge of having identical characters alongside the parentheses.
https://en.wikipedia.org/wiki/Side_effect_(computer_science)
Right! I'm used to methods returning the solution instead of changing the value of a parameter.
This comment is hidden because it contains spoiler information about the solution
Seems like the return type could be int[] instead of long[] since those will be digits.
Somewhat puzzled by the top voted solutions. Granted, they're pretty, but they'll fail for negative numbers.
And is it more efficient to sort the entire array rather than searching it for the two smallest? (Plus the requirement said not to change the initial array).
I realized that the first check is unnecessary, it said in the description that the array will have at least 4 elements.
My tests also included setups with negative numbers, hence all the checks in the code.
Saw other people upvoting this solution and decided to try it myself, but I realized that, even though it's pretty, it will fail if there are negative numbers present. So I would actually remove it if I could, but I don't know how.
I wasn't able to find a straight answer as to whether OrderBy changes the source it's applied to or just returns the reordered version. Will have to test it.