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.
I also thought that would be cool to solve this using regex!
In my case I used
join('')
enstead ofjoin('-')
and solved the /222/ problem by checking how many numbers are behind like this/^(...)*2{3}
You can see full code here:
https://www.codewars.com/kata/reviews/525caa5c1bf619d28c000338/groups/61e41f559a04f80001a6b80a
So
join('-')
stops /222/ from solving your example as it add an extra character at the end of each row.