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.
Agree
Totally agree!
OK! I promise! (vulcan salute)
Well, I had to hack in the words to get this result. ;) Thanks!
Hello,
The test code is indeed sensitive (tricky to test memory consumption and run time).
But there is a good reason it fails here. Let me precise the error message: you reach a memory limit.
Indeed, your code is "taking the chunks one by one", so that's good.
But you transform the chunk into an array with
.split('')
.Therefore, you make a copy of the chunk. So it takes more memory than necessary (and also slower). Especially at the end of the loop with
buffStr
hanging around.(memory threshold is pretty hard i know :p)
Good news: you are going to learn a new thing today :
String.prototype.charAt()
.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt
Basically, you don't need to use arrays. Just do:
Note that
buff[5]
also works. See http://stackoverflow.com/questions/5943726/string-charatx-or-stringx for the nuances.And then your code pass all tests :)
Tests cannot get changed after more than 500 warriors have solved them. See #123 and #163.