Ad
  • Default User Avatar

    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.

  • Default User Avatar

    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).

  • Default User Avatar

    Thanks for the comment: this is quite valid point to consider (which I very likely didn't consider when writing that solution). If I would be nitpicking, I could argue that the requirements can be interpreted so that the rules for a smiley face can be applied for substrings as well instead of the whole string in the array - and with this interpretation, 2 would be the expected result ;)

  • Default User Avatar

    yep, you are right. It doesn't fulfill the last requirement (which would then be missing from the tests as well then)

  • Default User Avatar

    This question isn't really related to preg_match_all function but rather to using regular expressions in general in php. But sure, these characters mean:

    the '/' characters are delimiters that enclose the pattern (http://php.net/manual/en/regexp.reference.delimiters.php)

    the '?' is used here to denote that the matched character ('-' or '~') can appear 0 or 1 time (http://php.net/manual/en/regexp.reference.meta.php)

  • Default User Avatar

    mmm, thanks for the pointer - will be checking those out. Was already thinking about the potential next steps (including the generic problem) but didn't yet have time to check whether something like that already existed :)

  • Default User Avatar

    Great kata - best one I've stumbled across by a large margin. Required studing some new concepts and working old school penning fsm and working with the transformations. Took me longer to get it right than I care to admit, but at least I can easily say that I learned some new stuff here. Just wanted to say thanks for this & keep up the good work.

  • Default User Avatar

    thanks. Yep, thought of that but just resulted in writing it in this more compact format (without that one extra line). In general, this solution is in any case more about using array functions in compact form - I wouldn't write this kind of code in real projects ever (instead I would write down the function in longer form that would result in code that is easier to read/understand by everyone).

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Could you update the data description a bit?

    it currently has the following row:
    'ABC' --> x=65, y=66, z=67 --> '656667'

    whereas this should probably be:
    'ABC' --> A=65, B=66, C=67 --> '656667'

  • Default User Avatar

    Anyone got an answer for this? Couldn't find any easy way of locating my own upvoted solutions either...

  • Default User Avatar

    Could you please update the test cases (php at least) so that it includes a case with integer strings (or alternatively change your kata description so that it speaks only about the float values)? Currently your test set accepts solutions that simply use floatval for the conversion, meaning that for parameter array ["1", "2", "3"] returning array [1.0, 2.0, 3.0] passes the tests (which is contradictory to the example in the kata description).

  • Default User Avatar

    It probably means that your solution doesn't work with integer string values as described in the problem description. Your solution returns [1.0, 2.0, 3.0] for parameter array ["1", "2", "3"] whereas it should return [1, 2, 3]. The test set seems to be a bit lacking as they are not testing this case.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...