Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
congratulations!like your method!
Thank's a lot for the explanation. Might be an feature idea to save the language version of with the solution.
This comment is hidden because it contains spoiler information about the solution
I tried your code, because it looks interesting with the "range + range" syntax. I get the following error:
TypeError: unsupported operand type(s) for +: 'range' and 'range'
Do you have an advice or explanation?
Hi! I found that
new Array(3)
is not produce[undefined, undefined, undefined]
. It produced[ <3 empty items> ]
. And we are cannot to interact with it by Array.prototype methods. We must to convert it to array withArray.from
for example.In the solution,
.reduce(:&)
could be replaced with.all?
.Negative values of
n
shouldn't be generated in the random tests.This comment is hidden because it contains spoiler information about the solution
Thanks everyone, your explanations helped me a lot.
You can create arrays like that: new Array(n), where n is quantity of elements. For example, new Array(3) will produce [undefined, undefined, undefined]. Besides, every array has join method, which creates a string from the array's elements and join's argument will play as separator, so that [1,2,3].join('anyStringYouLike') will be evaluated in '1anyStringYouLike2anyStringYouLike3'. And [undefined, undefined, undefined].join('String') will be evaluated in 'StringString'.
Hope this explanation will help to undestand this solution.
I believe Array is a class, and when passed a number like this, it returns an empty array of size n + 1 (empty meaning, each element is undefined).
Example:
Could someone please explain what's going on here?
Array(n+1).join(str)
I couldn't find anything on the net about Array() taking parameters. Is that an object or a method or what?
Thank you for your input
Yes, it is indeed reversed. Embarrassing.
Loading more items...