Ad
  • Default User Avatar

    @iamzuul, there are more than 3 different tests applied when you submit.

    You can see the test input if you log the argument to your function with console.log(...)

  • Default User Avatar

    Sure. Even worse; you have to construct an array representing the entire string before you visit the elements with reduce().

    It's a toy solution to a toy problem, but the straight forward imperative solutions are boring ;)

    I've submitted a boring solution as well now (with eager exit).
    http://www.codewars.com/dojo/katas/reviews/52774a314c2333f0a700068b/groups/528a437009e419289d000f20

    I've also submitted a tail-recursive solution, with eager exit:
    http://www.codewars.com/dojo/katas/reviews/52774a314c2333f0a700068b/groups/528a446509e419076d000f27

  • Default User Avatar

    @xDranik: randomising the order of the test might do the trick.

    @Bloodyaugust: no hard feelings, but I think it is clear that this is cheating in the same way it would be cheating to answer a math test in school by answers provided to you beforehand. In some cases (and katas!) the explicit goal is to pass the test-case, but in most the test-cases are merely there to validate that the solution meets the requirements for certain arguments.

  • Default User Avatar

    I think the calling sequence is backwards; the framework calls our function a number of times, with hints, in order to get a solution, but then we get the problem of the initial null guess.

    I'd prefer to providing the user with a "guess"-function (maybe as an arguemnt), to be called with the current guess, and having it return the indications, and then limiting the number of times this function may be invoked.

  • Default User Avatar

    I submitted a brute-force implementation by mistake ...

    I think the kata would be more interesting if you'd need something like a binary search to find a solution.

    Flagged with 'minor issues' due to this, but I'm not sure if that is in line with the protocol.

  • Default User Avatar

    Surely it's cheating; you're overfitting the function so it doesn't meet the requirements of the specification, only the test.

    I don't really care that you cheat, but it seems like a quite empty experience, and even if you gain some small amount of "honour" you gain no understanding and make no real progress.

    Your loss, the rest of us make do ;)

  • Default User Avatar

    Good! Then it's only a small matter of programming... ;)
    ( And the time to do it )

  • Default User Avatar

    The error message indicates that the solution fails for nthFibo(1) ( the 1-st Fibo ).

  • Default User Avatar

    This looks interesting!

    One question: are we guaranteed that the shapes will have an area?

    In other words, is this a legal shape:

    ++
    ++
    

    or is

    +-+
    | |
    +-+
    

    the minimum shape?

  • Default User Avatar

    I not an expert on the requirements of the various kyu levels, but level 4 is way off for this problem.

    The description for level 7 lists (among other things):

    • Iterating arrays and returning a subset of values
    • Basic data type manipulations

    which seems about right for this problem.

  • Default User Avatar

    Glad to see that not everybody is resorting to regular expressions on this one! ;)

  • Default User Avatar

    @nklein +1.

    The ownership-bit is a JS-centric "implementation detail".

    I think it is recursion when you call the "same" function belonging to another class (not just instance); a function is recursive if it is defined in terms of itself (directly or indirectly). In JS functions with the same name and same "contract" can be considered part of the same polymorphic function. I
    consider a toString() on object foo to be recursive if invokes toString() on object bar.

  • Default User Avatar

    Nice kata.

    I'd put something like "recursion encouraged" in the description though... ;)

  • Default User Avatar

    The instructions point to documentation for the filter() method:
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

    You have to write your solution in a way that uses this method, in addition to returning the correct answer.

  • Default User Avatar

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

  • Loading more items...