Ad
  • Custom User Avatar

    Updated the description: case-insensitively-alphabetical-order-of-appearance ought to be enough of a tearse spec for anyone with decent understanding of the spec language (English in the original case). Translations of katas is a feature I think could be really useful, but of course as with all translations, the output depends not only on the original text but also on the translator :)

  • Custom User Avatar

    Thanks for the good feedback @JohanWiltink. Each time I write a kata I have already forgotten what is and is not included in the "CodewarsSpec" test class, and for some reason the documentation always seems far/further than one click away so... 😄 When I eventually checked it (because I wondered about where you were supposed to stash the reference solution that you need in case of random test input) I did not notice the Test.randomize(array) → Array, Test.randomNumber() → Integer, Test.randomToken() → String, Test.sample(array) → object since they were are just tacked onto the end without even so much as a comment.

    Thanks again anyway, I'll see if I can make use of them in the future.

  • Custom User Avatar

    good point, sortBy is what we need - should be possible to do this without lodash as well

  • Custom User Avatar

    localeCompare, sensitivity base, wow I didn't know about that

  • Custom User Avatar

    I was renaming the function / the docs were lagging. Dang you guys are fast on the ball, hardly had time to hit Save :D

  • Custom User Avatar

    OK if that's how you wanna play this game - I can see some hardcoded solutions, so I'm gonna have to add radomized inputs for the final test.

    EDIT Done. Should invlidate some existing solutions @JohanWiltink ;-) Also reclassified as "Puzzle", in case people now have so many issues with reading the spec.

  • Custom User Avatar

    Can you explain what this instability involves, and what it means for the kata solution?

  • Custom User Avatar

    I'm not opposed to tagging it "puzzle". But it would be better if we could figure out a spec that explains the desired output better.

    Expected BbeehHilloTy do you want capitals first or lowercase?

    I want it exacly as it is: the letter present in the input, in alphabetic order, stacked in the order (from left-to-right) that they appear in the input. Obviously irrelevant of casing, since letters excisted prior to computer encodings.

    Avoid getting trapped only thinking in terms of ASCII codes. ;)

    There are no a:s. For b:s, the uppercase one appears prior to the lowercase one, so all the b:s add up to "Bb". The first "h" is lowercase, the second one uppercase, so the h:s stack up to "hH".

  • Custom User Avatar

    It would have been more interesting if it had a negative number in the final test cases as well, but ok, perhaps better to keep it simple.

  • Custom User Avatar

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

  • Custom User Avatar

    Again, any solution utilizing numbers.splice() mutates the original array, which specifically was not allowed according to the instructions. But the kata author forgot to assert that...

  • Custom User Avatar

    Or just use the spread operator Math.min(... numbers) instead.

    (Ref. https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Spread_operator)

    The solution is still invalid because it mutates the original array. The final kata test should have had a guard against that...

  • Custom User Avatar

    I seem to be one of the few to use .reduce() for accumulating the output! :-) I started out with .join() too, but decided to refactor it out.

    Other observations: my normal linter would kill me if it saw me using && for side-effects and unary ops (++/--) inside predicates, but they're fun to use as shortcuts here! It also pleases me that I got a chance to use do/while in JS - something which doesn't seem to happen often.

  • Custom User Avatar

    If you go with just return 0 and just press RUN SUITE, the test output looks as follows:

    Sampling getRandomInRange(0, 1) shows incorrect return values - Expected: '[0, 1]', instead got: '[0]'
    

    and I can't think of any way to make that more clear: it says that it sampled calling with parameters (0, 1) and it did not return the expected (random) values [0 and 1], but instead got [only the value 0].

    I suppose it looks more cryptic if the reader is less familiar with xUnit style assertion errors... Thanks for the input anyway, I will think about it - open to suggestions! :)

  • Custom User Avatar

    OMG what have I done?!? Such pain and misery! :-D

  • Loading more items...