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.
As matt said, it is no issue.
Probably more a suggestion than an issue.
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."
Sorry about that. I've updated the example test to use
Test.assertSimilar
rather thanTest.assertEquals
. The submission test uses a more sophisticated algorithm to check the results, rather than just comparing your result to another object.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
andnewLines
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:
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.
This comment is hidden because it contains spoiler information about the solution