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?
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?
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?
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
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! :)
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.
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.
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):
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.
Or none at all! This is intentional,
sum([1,2,3], [4,5,6], [7,8,9], () => 1)
=>3
is correct. Evensum([1,2,3], () => Math.random())
is a correct usage ofsum
. 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?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?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?
yes, they are >:)
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.
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 (asObject.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! :)
My bad again, you are absolutely right with this properties stuff.
Thank you for your feedback!
.
This comment is hidden because it contains spoiler information about the solution
Done.
Your suggestion seems overcomplicated, as it is ok to go with
new Strip([...strip.raw()])
. It also does not work, throwingTypeError: Property description must be an object
, asstrip
is, obviously, not a properly-defined descriptor.I guess something like this might be an option (at least it works as expected):
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 likeuStrip._points = [0]
will break everything, but you've got the point. Nevertherlessnew Strip([...strip.raw()])
works as intended.I was afraid that asking users to interpolate values for themselves might have been considered as too complicated :) thank you for your feedback!
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...