Ad
  • Custom User Avatar

    Memoization via a stream isn't good enough to solve this kata. You'll have to study the link provided in the description.

  • Custom User Avatar

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

  • Custom User Avatar

    I tried it and it failed in two of the test cases (I think where one array was empty and the other was null)

  • Custom User Avatar

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

  • Custom User Avatar

    group() without parameter corresponds to all the characters matching the regex pattern. Group(1) corresponds to the group 1 in the regex pattern.

    With the string abc-def and the regex pattern .-(.) group() returns c-d and group(1) returns d

  • Custom User Avatar

    My solution now fails the Woof-shhh-woofwoof! test case as it should.

    Random tests can generate woofless subsequences too

    What are the odds of this happening? Unfortunately they seem to be too low so I can't consider the issue resolved. My wrong solution still passes 50000 random tests consistently.

  • Custom User Avatar

    That can't be true. I, for example, have this test

    assert.strictEqual(woofDecoder("Shhh! Shhh-shhh!"), "nothing to decode!");
    

    To make sure, I added this in my test cases

      it("given \"Woof-shhh-woofwoof!\"", function() {
      assert.strictEqual(woofDecoder("Woof-shhh-woofwoof!"), "b");
      });
    

    Random tests can generate woofless subsequences too

    Is it now resolved?

  • Custom User Avatar

    Considering each subsquence one woof (even if it doesn't contain a woof) wouldn't get you through the tests. If I understood you wrong, please clarify

  • Custom User Avatar

    I changed the beginning of the third item in the "things to keep in mind" list to

    1. Sequences consist of hyphen-separated subsequences. Each subsequence can contain either zero or one woof (which, in turn, represents zero or one step in the alphabet traversing).

    Also, I highlighted the word "letters" in bold while making some minor edits to make the meaning clearer

    1. Justin's audio recorder is not a very good one. Sometimes, it inserts some random sounds that should be ignored. With that in mind, a woof is any string of letters that has a "w", an "o", another "o", and an "f" – in that order but not necessarily consecutively and irrespective of the case. If an input string has no woofs, the function should return "nothing to decode!"

    You can re-raise (hopefully, providing additional clarifications) in case you deem it insufficient

  • Custom User Avatar

    Do you think it's unclear? How do you think I can improve it?

    Each woof subsequence can contain either zero or one woof (which, in turn, represents zero or one step in the alphabet traversing). For example, in a woof sequence "Woof-shhh-woofwoof!" there are three subsequences: "Woof", "shhh", and "woofwoof". The first one contains a woof, the second one doesn't, the third one also has a woof (not two). It means this woof sequence of two woofs in total stands for "b"

    also

    a woof is any sequence of letters

    The expected output of your example string is nothing to decode! since neither of the subsequences (which are: 'w', 'o', 'o', and 'f') contains a woof

  • Custom User Avatar

    Fixed

  • Custom User Avatar

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

  • Custom User Avatar

    I think there's a confusion in the thread. The author's solution generates a geometric distribution, which is not wrong per se but generates a distribution that gives short length most of the time and rarely (but can) generate long lengths. See graphs at: https://en.m.wikipedia.org/wiki/Geometric_distribution

    The fact that NunoOliveira and Hobovsky are talking about 'the range' is an indication that there's just a misunderstanding.

    Hobovsky, your kumite showcases a common mistake when writing tests generating a uniform distribution, but that's not what happening here. Note that the condition here does not depend on the loop counter.

    I don't think it's a problem per se that the tests generates a geometric distribution. It's a common mistake to use Math.random() in the loop condition but it's not what happening here.

    I'm closing this issue as the author's code is most likely working as intended.

  • Custom User Avatar

    Again, why does that happen under such circumstances?

  • Custom User Avatar

    Because it wasn't fixed. The issue still remains.

  • Loading more items...