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.
Kata description is "Given an array with exactly 5 strings". And there is no specifications / requirements how the method should work if the argument array contains different number of strings.
It doesn't work with ['a', 'a', 'a', 'b']
i agree, but they can also make you familiar with built in functions, specially beginners like me, i love getting to know the bif hands-on!
replacement may contain references of the form \n or $n, with the latter form being the preferred one. Every such reference will be replaced by the text captured by the n'th parenthesized pattern. n can be from 0 to 99, and \0 or $0 refers to the text matched by the whole pattern. Opening parentheses are counted from left to right (starting from 1) to obtain the number of the capturing subpattern. Note that backslashes in string literals may require to be escaped.
No, it's not. 99 is
'XCIX'
.Is
'IC'
a valid Roman numeral for 99 ? I thought so ; and this code wouldn't manage these kind of forms.wow, this is another level. it's crazy to think the amount of "ifs" that I used and this could have been solved more simply
i don't see any reason to use built in funcions in these kind of exercises, i believe those are meant to practice, to understand how things work, taking these shortcuts doens't teach anything
TIL about preg_match_all and how its return value is the number of matches.
The rating of this solution shows how the developers tend to ignore the description in favor of a solution with less lines.
'CCD'
is not a valid roman numeral:'CD'
is 400'CCC'
is 300So
'CCD'
won't be passed to the function.Will give incorrect result for 'CCD' (for example). It will return 400, but should 300.
Based on the older comments on the discussion chain, it sounds like the test cases didn't originally match with the kata description (i.e. the random tests could test the solution with parameter value 0).
Why start the range at 0?
I think this solution is fit perfect for given description. The only one thing which I would correct is implode($arr). There is no need in delimiter at all.
Loading more items...