Ad
  • Custom User Avatar

    the passed function may handle only one argument or several

    Or none at all! This is intentional, sum([1,2,3], [4,5,6], [7,8,9], () => 1) => 3 is correct. Even sum([1,2,3], () => Math.random()) is a correct usage of sum. The direct analogy is something like [1,2,3].map(() => 1) => [1,1,1]. My guess was that examples #2 and #3 perfectly clarify this behaviour. Do you think I need to explicitly state this in the description?

  • Custom User Avatar

    Hi, I agree that it is not clear from the description that the default value must be 0, especially in a case like sum([], () => 12345), I will update the description. Could you elaborate the "one cannot always do the task as explained" a bit further, probably by providing some examples?

  • Custom User Avatar

    Hi catchaser, yes, you are right, the result must be 68. I don't understand why you are seeing this (all test cases expect "0"), I just checked and everything works fine for me. Probably something wrong with codewars' test runners? Are you using Node v10.x?

  • Custom User Avatar
    3. so, if
    
         ln(N)/ln(2)
         
       is not a integer, then N is not of a form
       
         2^x = N, where x is an integer
         
       thus it has at least two '1's in its binary representation
    
  • Custom User Avatar
  • Custom User Avatar

    great kata, but I think you should make it more obvious, that in 'leading-edge case' the function shouldn't be called after the specified timeout.

  • Custom User Avatar

    Yes, of course I tried your code. And I've used it countless times in industrial projects. I always use hasOwnProperty when iterating over objects' keys this way though (as Object.keys does this for me).

    You definitely have a good point, I'll adjust the kata and resolve the issue when I have time.

    Thanks a lot for your suggestions & detailed explanations! :)

  • Custom User Avatar

    My bad again, you are absolutely right with this properties stuff.

  • Custom User Avatar
    1. In my opinion, stating all the necessary details will oversimplify the kata, that's why the description is intentionally left vague. What I mean, is that the phrase 'slightly more comfortable' should've already told you, that the expected behaviour of brand new 'assign' should resemble the behaviour of the classic 'Object.assign' (and it takes multiple arguments). If you think that this is too ambiguous and my intent to not specify all the details was wrong, I'll correct the description.
    2. Enumerability doesn't really matter, as this kata (and all other katas, I guess) has a purpose of training 'fundamental', not 'industrial' knowledge. I mean, the ultimate goal of CW is to train language features, algorithms and fundamentals, not the side effects of different implementations. Correct me here, if I'm wrong.
  • Custom User Avatar

    Thank you for your feedback!

  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    Done.

    Your suggestion seems overcomplicated, as it is ok to go with new Strip([...strip.raw()]). It also does not work, throwing TypeError: Property description must be an object, as strip is, obviously, not a properly-defined descriptor.

    I guess something like this might be an option (at least it works as expected):

    const uStrip = Object.assign({}, strip);
    uStrip.__proto__ = strip.__proto__
    

    I'm not a certified programmer though, so any objections to this are welcomed.

    UPD: of course, it doesn't really work as expected, because it is just a shallow copy, so something like uStrip._points = [0] will break everything, but you've got the point. Nevertherless new Strip([...strip.raw()]) works as intended.

  • Custom User Avatar

    I was afraid that asking users to interpolate values for themselves might have been considered as too complicated :) thank you for your feedback!

  • Custom User Avatar

    So I've published a kata, but it didn't appear on the list of beta katas. What might be the problem?

  • Loading more items...