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.
Got the same issue. In my case it was because I was overwriting Array.prototype.flat.
Even though it says it's using node8 and flat was introduced in v11, it still a had problem with that somehow. So avoid overwriting any build-in objects.
nice
Retired as a duplicate.
arrrrggggg this is smart and so obvious!! I totally forgot about gsub.
Mutating the input array breaks the random tests.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/191.
Please join the discussion to help us identify duplicate kata and retire them.
thx a lot for your reply, the current impl via passing a string only because that ruby cannot denote identical syntax as perl6 does, but your suggestion is very reasonable, i will modify the kata to make it more pragmatic when i'm free.
Thank you for your feedback. In fact, there are similar test cases, but it looks a bit complex, I replaced with what you mentioned.
Thank you for your feedback. I understand that the current design might not meet your expectations. The intention of this kata is to explore the concept of emulating Perl 6's whatever expression in Ruby, rather than focusing on parsing syntax extensively, so I made some simplications.
I also wanted to use Ruby's internal DSL to design this kata, but doing so would deviate from the syntax of Perl 6.
But your design based on
varargs
&block
is the most concise one undoubtedly. What do you think is the most suitable difficulty for this kata?Tests like
seq.zip(seq.drop(5)).take(5).force
should be added to sample tests too, otherwise random tests blow up in nasty ways, which makes the failed tests in actual tests hard to see.It's unclear what is being passed into the function
whatever
. A natural implementation would assume something likeEnumerable.inject
:whatever(1, 1) { |a, b| a + b }
, but turns out we're just stuffing a raw string inside? And not evenwhatever(1, 1, 1, "* + * ... *")
?This is very unexpected, and certainly doesn't look like a good design for this at all, when there is stuff like
Set.new([1, 2, 3]), *.map(&:succ).to_set ... *
in the random tests, and the whole thing turns into "how to parse the input good enough". I do not think "parsing syntax that emulates another language" is the supposed difficulty of this kata.I would say that's a bit messy syntax. Function should be declared at least with 'const' keyword.
If the resulting array is empty, calling
first
will yieldnil
, which needs to be converted into0
. This can be done either by usingto_i
or|| 0
.Why would .to_i be necessary? The array consists of integers only.
It probably would be, if it was ruby only (or any other language which allows same trickery, alternatively input size range was known beforehand) and expected regex instead of function.
Loading more items...