Ad
  • Custom User Avatar

    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.

  • Custom User Avatar
  • Custom User Avatar

    Retired as a duplicate.

  • Custom User Avatar

    arrrrggggg this is smart and so obvious!! I totally forgot about gsub.

  • Custom User Avatar

    Mutating the input array breaks the random tests.

  • Custom User Avatar

    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.

  • Default User Avatar

    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.

  • Default User Avatar

    Thank you for your feedback. In fact, there are similar test cases, but it looks a bit complex, I replaced with what you mentioned.

  • Default User Avatar

    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?

  • Custom User Avatar

    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.

  • Custom User Avatar

    It's unclear what is being passed into the function whatever. A natural implementation would assume something like Enumerable.inject: whatever(1, 1) { |a, b| a + b }, but turns out we're just stuffing a raw string inside? And not even whatever(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.

  • Default User Avatar

    I would say that's a bit messy syntax. Function should be declared at least with 'const' keyword.

  • Custom User Avatar

    If the resulting array is empty, calling first will yield nil, which needs to be converted into 0. This can be done either by using to_i or || 0.

  • Default User Avatar

    Why would .to_i be necessary? The array consists of integers only.

  • Custom User Avatar

    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...