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.
Hello there, I'm just leaving this reply in case someone struggles with the code timing out.
To solve this problem you generally CAN'T use higher order array methods inside ANY loop (in Javascript the methods used for this case are generally Map or Reduce). Calling Higher-Order Array methods inside a loop will make the time to execute the code significantly higher, and the solution will fail.
You CAN'T use NESTED LOOPS (that's implied by the last point). Perhaps a solution using nested loops can still pass the tests, but it's far from optimal and it's not the point of the Kata. The Kata has huge test cases because it's testing if you can make your code efficient enough.
You CAN use two different loops that aren't nested, and most common solutions would use this.
You also CAN do simple operations inside a loop, like substracting or adding numbers, or pushing a value to an existing array. You can do simple operations like this which don't involve creating new arrays or looping through the totality of an existing array.
This Kata seems like a 6 Kyu to me but it may require some previous knowledge of Big O Notation and Time Complexity to understand why some solutions work and why some don't. Having an awareness of Big O Notation can make all this very clear, and I encourage any programmer to research this topic.
Here's a video that might be very useful to get anyone started.
You don't need to use a generator. My solution was actually bone simple. Try thinking about how you can tally what you need and add to a list as you read through the input list.