Ad
  • Custom User Avatar

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

  • Custom User Avatar

    The PHP version is quite lame in its checking of "count" use.

    It literally regexes "/count/i" so my intermediate $count variable was erroneously flagged as hacking.

    I just renamed it to $c and it worked.

  • Custom User Avatar

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

  • Custom User Avatar

    Great investigation @trashy_incel.

    Indeed my beef was, among other things, that it was expecting stuff like "123abc" to pass.

  • Custom User Avatar

    the setup of this kata in PHP has really big issues. not only are most solutions wrong, including the author's, because they use the value 0.0 to detect invalid inputs, which means they fail the simple test case assertSame(0.0, parseFloat("0.0")), but, contrary to all other languages, the random tests expect 123.0 for something like "123abc", just because (float) / floatval() in PHP behaves differently than most other languages (e.g. for the same input JavaScript returns NaN, Python raises a ValueError, etc.)

    the description does not indicate the expected behavior at all, which means all languages likely fallback to the behavior of their builtin.

    I made a fork there adding the "0.0" fixed test and replacing the reference solution with something saner, but i'm not going to self-approve, as this will invalidate all solutions.

  • Custom User Avatar

    I checked the history of versions, those invalid solutions managed to pass because tests used the loose equality assertEquals() when the translation was published. it has since been changed to the more robust assertSame()

  • Custom User Avatar

    all the previous solutions don't work either

    how did you determine that ? I tried a dozen solutions from the Solutions page and most worked. a few old solutions did not work because they perform no error checking at all and return 0.0 instead of null for invalid inputs like "abcd"

  • Custom User Avatar

    I am not saying that the setup of this task is great, but I just completed this task in PHP.

  • Custom User Avatar

    The PHP version is impossible to pass, all the previous solutions don't work either.

  • Custom User Avatar

    Nah, it's poorly written.

    There are no tricks, everything you need to do is literally written in the description: find the score for each person (gives you the formula) and sort the players by their score (or alphabet).

    But it is absolutely written in a poorly convoluted way.

  • Custom User Avatar

    duplicate of this issue

  • Custom User Avatar
    • fixed the order of expected and actual

    • fixed by upgrading to PHP 8.0

      • root cause of the issue: the reference solution used usort

      the manual says:

      If two members compare as equal, they retain their original order. Prior to PHP 8.0.0, their relative order in the sorted array was undefined.

  • Custom User Avatar

    Something's wrong with php.

    Even solutions that should've been valid do not really work.

    I can't get a fresh one to work either.

    https://www.codewars.com/kata/reviews/5dea647d77902f0001e96d92/groups/5debd0568841740001276d82

  • Custom User Avatar

    Very poorly described, very few test examples, not a great kata at all.

  • Custom User Avatar

    I see, that's a good point then, if everybody calls them closures it's important to stick to them so everybody uses a common language.

    That being said, I feel this is a limit on php part, being an implementation-derived rathen than spec-derived language (such as C, JS, Java and others) terminology is often used in a confusing and improper way.

    That was a helpful discussion in any case for those that will read comments.

  • Loading more items...