Ad
  • Custom User Avatar
    Progress
    Rank:7 kyu
    Honor:86
    Leaderboard Position:#201,387
    Honor Percentile:Top 81.96%
    Total Completed Kata:5
    

    Corey, this is not about you personally!

    But I am amazed that 5 kata and 86 honour is apparently enough to publish a kata now. I thought the bar was higher ( and it was not high enough already ). Can somebody ping an official? ( A real one, not one of these "solve 3000 kata and become a self-appointed moderator" like me. ) Did CW just go down the drain entirely?

  • Custom User Avatar

    PHP tests use json_encode to test key order in mappings, which is extemely poorly designed and should not be expected to work.

    The returned structure should be redesigned to something like [{name: 'a', score: 5.33}, {name: 'b', score: 5}, ...]. Don't do things the utterly wrong way.

  • Custom User Avatar

    ( JS, possibly others )

    Needs random tests.

  • Custom User Avatar

    I don't know PHP, so the following is ( mostly ) applicable only to JavaScript.

    Rounding is not a good way to make floating point numbers comparable. Comparison should be done with an error margin ( this would apply to both tests and solutions ).

    Objects are not the most natural way to encode ordered lists in JS. Arrays are much more common and have much better native support for various operations. ( Note that your example solution exclusively works with intermediate arrays, even if it sometimes encodes intermediate values as objects. ) This is unnecessarily and artificially making the kata more complicated than it needs to be. This is not a best practice in general ( and not a good way to increase the difficulty level of the kata, if that was your intention ); it's a simple matter of choosing an inappropriate datatype. JavaScript has limited support for key/value-pair ordering in objects. ( That is to be read as "at defined times, it has no such support; at other times, it has very inflexible support, namely insertion order only, and no reordering support". )

    return an empty array, []

    That should be an empty object, {}. It would be better to correctly specify this than to show it in the initial code. Language-specific text in the description is possible.

    float

    JS only knows Number.

    All test cases have been provided to you. Adhere to these test cases.

    What does that mean ?

    Wait, does that actually mean the submit tests are the same as the example tests? You can't do that; you should also have random tests, and you don't want those in your example tests.

    initial code function rankPlayers($players) {}

    that argument is next referred to as players. That $ might work in PHP; in JS it's just part of the name and should be taken out.

    initial code // player name as the array key

    that should say "object", not "array". ( I'm starting to think PHP doesn't differentiate between arrays and objects? Well, JS does! )

  • Custom User Avatar

    For JavaScript: Return an object of players in the order they rank

    Key ordering is not part of dictionary equality in almost all languages, which basically means this requirement is not used at all, and hence makes no sense.

    Why is JS returning an object instead of an array?

  • Custom User Avatar

    Description for JS:

    'Jack Johnson': { 'speed': 5,'agility'=>4,'quickness': 3 },

    => should be :.

    Also,

    Below are examples in both PHP and JavaScript:

    JS does not use {} for arrays.

  • Custom User Avatar

    Who wrote the initial code for JS version? Argument name should be players, not $players.

    Also, !players do not make sense in JS because objects is always truthy. The first line in the function body is superfluous.