you are absolutely correct, using a pattern as static variable is about 3-4 times faster.
Correct me if I'm wrong but isn't this solution kind of inneficient in terms of performance in a high concurrency scenario??
The thing is that everytime you invoke String.matches it has to compile the regex before evaluating the String. If you compile
the regular expression in advance using an static variable with Pattern.compile() it will perform way better than this solution.
yeah, I thank it's good practice. Thanks!
Big integers should be banned for this kata imo. Otherwise it's not about the algorithm but about how much memory you have.
Could be more interesting if the Kata's primary language did not support big integers.
Also, the long list of numbers shown on the description is somewhat distracting. Can't we just show an example using, say, five 50-digit numbers?
added more random tests.
I think the first ten digits of the sum is clear enough but i will add an example
A break only exits the switch-case statement. On the other side a return exits the whole method, so this is valid, too. As you can see, in any case there will be a returned value.
Why didn't you type 'break' in each case? Is it not necessary?