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.
Hi Chrono.
Apologies for the delayed response, I have been disconnected over the weekend.
Ok, that makes sense. I will have a think and see if I can figure out how to use the pattern logic instead of building the entire queue.
Hopefully I can figure something out!
Once again, I really appreciate the help.
Cheers,
Dave
About the pattern:
Try using some math to predict the value on the passed position without building the whole list, that's the most I can tell without spoiling it.
Hi Chrono.
Thanks so much for your detailed response, it's a great help.
Could you perhaps give me an example of the kind of patern you're refering to?
Please excuse my ignorance, I am just learning and there are clearly huge gaps in my knowledge as I'm at a loss regarding this one.
Cheers,
Dave
Building the queue like that won't work (also, that's not a copy, it's another reference to the same array, mutating queue will mutate names because the array is the same). Shift and slice are in the worst case O(n) so those count like nested loops in time complexity. Also, building an array with so many items will exhaust memory at some point. You'll have to find a pattern instead so you can save cycles.
This comment is hidden because it contains spoiler information about the solution
Could you post your current code using markdown formatting and marking your post as having spoiler content? Some array methods have loops under the hood, and that's why it times out.
Hi Chrono.
It's not actually a nested loop. It's just a single 'while' loop containing a number of array methods and then a return statement outside of that.
I will consider your cryptic clue, but I'm not sure I can make sense of it! Can you give me anything else??
Cheers,
Dave
Nested loops won't work, single loops works tho, use a more mathy approach.
Hi guys.
I'm enjoying this kata, but am having trouble with optimization. My code is doing what it needs to do, but timing out with the big numbers!
I am using a loop (have tried both 'for' and 'while' loops) with some array methods inside it to reshuffle the queue, but it clearly is not performant enough.
Could anybody give a clue as to what I could try to make my code more performant?
Many thanks,
Dave
My comment was related with the new comment above... I've was timed out and I could'nt achieve the challenge.
Hi. Thanks very much for your response.
Yep, clearly I'm timing out on the long strings. I guess I need to keep working on optimizing my code then!
Cheers :)
(for JS): There's 10 fixed tests, 50 short string tests, and 10 long string tests (70 total), so you're probably timing out at long strings =/
For reference, average solution takes about 9-10s.
Hi guys.
How many tests are there? I am getting '60 passed, 0 failed, Exit code 1' (in 30ms), which relates to the 12000ms timeout. But are all the tests not completed already?
I'm not sure what is timing out.
Thanks!