it's a solution if it passes the test cases.
Is it a solution when, instead of implementing the solution, the function just calls another function that solves the problem?
If there were such tests then obviously it cannot be submitted (and if the tests are then changed, this solution will be invalidated). But sometimes the latter doesn't work, so... ;-)
But hey exists. That is the only reason why I asked
P. S. I do not try to say that you solution some how bad. It is indeed best practice. I just wondering were these tests at the time when you submited your solution or not.
Because nobody expects or tests out of specs things. They just don't exist for our purposes, so why bother even thinking about them?
The function always takes 2 parameters. Why would I handle these edge cases since there is no test for them?
Did not see how you managed to pass all the tests. What if pattern parametr will be missing and what if both will?
This comment is hidden because it contains spoiler information about the solution
I am don't sure about double fitering over the array. What about the perfomance speed?
But looks great! Best Practices indeed!