Ad
  • Default User Avatar

    As matt said, it is no issue.

  • Custom User Avatar

    Probably more a suggestion than an issue.

  • Default User Avatar

    I banged my head against this for a while, so I'll say to pay attention to "Each value should be in the range 0-255."

  • Default User Avatar

    Sorry about that. I've updated the example test to use Test.assertSimilar rather than Test.assertEquals. The submission test uses a more sophisticated algorithm to check the results, rather than just comparing your result to another object.

  • Custom User Avatar

    Hello,
    Your solution isn't that weird. Actually I'd say you are on a good path!
    Only one loop, no regexp, ... seems clean and efficient.

    But indeed you'll likely get a "Process was terminated. It took longer than 6000ms to complete" for now, because there are a couple of bugs.
    In order to fix this, I recommend you to add temporary console.log() to troubleshoot how far you go in the parsing.

    Also take the time to re-read all your code.

    Let me help you with the following tip: in newWords and newLines functions, you are using String.prototoype.indexOf to look for a specific char, and then do some things according to it.
    That's good. Also, you are using the facultative second parameter to specify a starting index, which is really a good idea to have a fast implementation: you jump from word to word (or line to line), rather than char by char.
    However, the second time you are using the indexOf, you forgot the second parameter! Therefore the second search starts from the beginning of the string.
    Thus, you might end up in an infinite loop. Indeed, indexOf might return a value smaller than the current index, leading to infinite loop.
    Exemple:

    chunk.text = "Once upon a time"
    
    # first loop
    .indexOf(" ", 0) = 4
    .indexOf(" ") = 4
    i = 4 + 1 = 5
    
    # second loop
    .indexOf(" ", 5) = 9
    .indexOf(" ") = 4
    i = 4 + 1 = 5
    

    It would be weise to store the indexOf result in a variable and re-use it rather than searching again a second time in the string.

    Also it seems you forgot to call this.reader.getChunk(); in the loop ;)

    Let we know if you're still having trouble.

  • Custom User Avatar

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