Ad
  • Default User Avatar

    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

  • Custom User Avatar

    About the pattern:

    ["a", "b", "c"] ->
    ["a", "b", "c", "a", "a", "b", "b", "c", "c"] ->
    ["a", "b", "c", "a", "a", "b", "b", "c", "c", "a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"] -> ...
    

    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.

  • Default User Avatar

    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

  • Custom User Avatar

    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.

  • Default User Avatar

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

  • Custom User Avatar

    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.

  • Default User Avatar

    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

  • Custom User Avatar

    Nested loops won't work, single loops works tho, use a more mathy approach.

  • Default User Avatar

    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

  • Default User Avatar

    My comment was related with the new comment above... I've was timed out and I could'nt achieve the challenge.

  • Default User Avatar

    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 :)

  • Custom User Avatar

    (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.

  • Default User Avatar

    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!