Ad
  • Custom User Avatar

    JavaScript Translation

    I suppose this task was made specifically for Ruby, but you can do the same thing in JS too

  • Custom User Avatar

    Do you know what 890625n is?
    Do you know what big integers are in JS?

    EDIT: OH I am stupid, and the kata is Ruby only.

  • Custom User Avatar

    how do i solve this ? expected '890625n' to equal 890625n

  • Custom User Avatar

    @Iron Fingers, the random tests call to_i to check if the result type is an Integer. Then it calls to_i again to check the value, not on the return value of the first to_i. If your implementation resets the number on the first call to to_i, just cache the last value and return it on the repeat call.

  • Custom User Avatar

    Why is there a discrepancy between fixed and random tests?

  • Custom User Avatar

    (Can you see this ^?)

  • Default User Avatar

    I tried applying the to_i twice in the sample tests and it does work. Like you said applying to_i to an Integer shouldn't return 0 and it clearly is not returning 0 in the sample tests. Not sure what else to try.

  • Custom User Avatar

    yup, this was after farekkusu's update. the function to_i is called two times in random tests, and only once in sample tests.
    Just try to get rid of that, you'll be done.

    Honestly I don't think this can be treated as an issue, because applying .to_i on Integer should not return 0.

  • Default User Avatar

    I am seeing a very peculiar issue. All random tests fail saying that my code is returning 0. However if I try for the same number in my own tests they pass.

  • Custom User Avatar

    Fixed.

  • Custom User Avatar

    Needs random tests

  • Custom User Avatar

    My 2 cents:

    While in a "learning" perspective this would be considered "cheating" as it completely misses the (might or might not exist) lesson, it's completely irrelevant to what best practice is. Best practice is simply the most efficient and readable code, period. Showing the explicit form as the best practice teaches you to not blindly applying loops to problems all the time, just like you'd always use good external libraries and built-in objects so you wouldn't have to reimplement everything or write code in a too low-level manner. That's how programming irl works.

  • Custom 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

  • Custom User Avatar

    First, how would deriving the series math not be the best practice (even from a learning perspective)? Loops and recursion are costly, and I find a lot of my job (software engineer) is reducing inefficiencies in hastily-written code. When presented with a series, every programmer's second thought (the first being, of course, loop or recurse this) should be, "Can I math it?" This is the 6th kyu; the training wheels are coming off, and efficiency should matter.

    Second, everyone should Google everything they don't know at all times. Heck, I derived the series math, but I ended up with an equation with respect to triangular(n + 1) that's less efficient than this one, and it took me 10 times as long to do it. I didn't learn anything doing that, I just applied what I already knew. That's a waste of my time. I could have spent that 10 minutes reading about why the series progresses the way it does, instead of just deriving a solution that works.

    In my experience, the problem with a lot of programmers is that they will bull-headedly apply what they know (loop/recurse everything!), even if it only kind of works (or works poorly), instead of finding a different, better approach (Google the series). If someone decides to copy-paste the solution without learning anything, well, that'll only get them so far, even in CodeWars. Additionally, if someone is on CodeWars, they've indicated a desire to better themselves, so I'm willing to give them the benefit of the doubt and assume most people aren't just copy-pasting.

  • Loading more items...