Ad
  • Custom User Avatar

    Empty string is a special case which doesn't really make sense in a reader.
    But anyhow, that would means nothing, thus :

          test4:
          {
            text: "",
            words: 0,
            chars: 0,
            lines: 0
          }
    

    i do agree this is in conflict with the "Returns at least one char" instruction
    (i don't remember if this was in the description i specified 9 years ago or if someone added that line since then)
    but defensive programming is always recommended and those values are easily testable

    as soon as there is one char, you get a line and a word

          test5:
          {
            text: "A",
            words: 1,
            chars: 1,
            lines: 1
          }
    

    but there is a special weird case, what if the text as chars, but it only contains spaces ?
    ...
    there is no word!

          test6:
          {
            text: " ",
            words: 0,
            chars: 1,
            lines: 1
          },
    
  • Custom User Avatar

    Or just randomize tests order as a first step?

  • Custom User Avatar

    Yeah sure, good luck figuring that out without solving the kata first.
    Feel free to brutforce and cheat the kata. It's not about that, it's about finding a performant logic.

    For this very kata, generating random tests would prove challenging. Possible though, but it would generate meaningless sentences and add a great complexity in the tests logic.
    Feel free to submit a PR.

  • Custom User Avatar

    Please clarify why this is an issue ?

  • Custom User Avatar

    Sure, feel free to submit a pull request to improve the tests.
    This kata was made almost 10 years ago, out of generosity on my free time, and is free.
    You can't expect it to be bulletproof or with a gold level support.
    And, if you try to think as the test developper, you'll see it is challenging to simulate memory limitation with the provided tools.

    Btw, Which solutions violate the rule ?

    The whole point of this kata is that it is possible to respect the rule and code efficiently. If choose not you, it's your problem, not really mine.

  • Custom User Avatar

    Approved, thanks!

  • Custom User Avatar

    I'm sorry .reset() got you confused. You choose to focus on the wrong things. The template is quite straightforward:

    DocumentParser.prototype.parse = function()
    {
      // TODO: Code Here!
    };
    
  • Custom User Avatar
  • Custom User Avatar

    hmm right, i forgot about that. It's difficult to check for literal regexp... Sorry for the time lost.

  • Custom User Avatar

    you should be able to use comments. RegExp are disabled like this: RegExp = undefined;

  • Custom User Avatar

    Hello,
    Sorry I didn't catch your message at the time.

    I think it was a temporary codewars error. It is working right now (just tried to submit your code).

  • Custom User Avatar

    Hello, I'm the kata author.
    Are you still having this issue?

    I've just tried to click Attempt with a valid solution and it works.

    In case it still doesn't work, please provide your solution (here or on any pastebin).

  • Custom User Avatar

    You're correct regarding the string "t four dead.Zombie ipsum" for the memory test.
    But not correct on the numbers. The standalone text is:

    • length = 1231, which turns in:
    • words: 176
    • chars: 1215
    • lines: 17

    The standalone text is repeated 5109x2x10= 102180 times.
    (5109 times to fill memory with ~6Mo and a trick to duplicate this by 2 so that getChunk returns a ~12Mo string each call which forces you not to allocate more memory ; and repeated 10 times indeed).

    102180*176 = 17983680 should be the correct word count

    I've added an extra space between each block so the new characters count expected is: 124250880

    I agree it not cool to have a "dead.Zombie" in a test case so I've just updated the test.
    However, this is the last test case, you should already have a robust code with previous tests.

    Adding random is a bit more complicated. I don't have time for this.
    The goal of the test is to have fun and learn things.
    If you look at people solutions, most don't use a hack.
    This is not an official exam. If people don't play by the rules, it is their problem.
    But they take a risk because I can update tests anytime.

    Thank you for your feedback.

  • Custom User Avatar

    Didn't get a notification, thanks for pinging me again.
    Ok let me take a look at your message about test case 44.

  • Custom User Avatar

    >.<
    I should add some random test cases to avoid hard coded stuff like that

  • Loading more items...