Seems like that's the bug for Ruby testing; raised an issue about that
This comment is hidden because it contains spoiler information about the solution
See the issue above. When you mutated the input, you changed the expected value, so even if your result was ok, the tests compared it against a different value.
If it only fails random tests, then one possible reason is your code mutating the input array, check that.
Added ;-)
You're using .digits which is actually very slow for this. There is a much faster way ;-)
.digits
You shouldn't write a function, you should only write the regular expression. Sites like regex101.com could help.
Loading collection data...
Seems like that's the bug for Ruby testing; raised an issue about that
This comment is hidden because it contains spoiler information about the solution
See the issue above. When you mutated the input, you changed the expected value, so even if your result was ok, the tests compared it against a different value.
If it only fails random tests, then one possible reason is your code mutating the input array, check that.
Added ;-)
You're using
.digits
which is actually very slow for this. There is a much faster way ;-)You shouldn't write a function, you should only write the regular expression. Sites like regex101.com could help.