Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • If the keys are the intergers from 0 to n, a list is better than a dict.

    Why do you use separate loops for the first n customers? General algorithm works with them.

    You search for minimum value 2*n+1 times for each customer, one time is sufficient.

  • From description:

    There is only ONE queue serving many tills, and
    The order of the queue NEVER changes, and
    The front person in the queue (i.e. the first element in the array/list) proceeds to a till as soon as it becomes free.

    • At time 0:
      2 goes in one of the tills
      3 goes in the other

    • at time 2:
      10 goes in the first till (used by 2, now free)

  • Oh, I'm confused, in the third example we have 2 tills and 3 customers, {2,3,10} This means that in one of the tills, two customers go through {2,3} and in the The second till,the custome who takes 10 seconds to cross the trough the second gate, now this means that in the first till 5 seconds and in the second till 10 seconds, customers need to cross the gate, according to inclusion–exclusion principle we have: n (A U B) = n (A) + n (B) - n (A ۸ B);
    Time = 10 + 5 - 5 = 10
    Why is it written that the function must return 12?

  • I am confused on what to do, if the tills is equal to 2 ect...

  • What does it mean by tills?

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

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

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

  • It took me several attempts, but in the end the algorithm is too slow. Idk how to proceed.....

  • Yep, thanks. My algorithm is wrong, it just happens to pass a lot of the tests.

  • The tests are ok, are you confusing the logs? They appear above the test result.

  • I hesitate to claim that it's the tests and not my code, but this seems to be undoubtedy wrong. I think the automated tests are not passing the correct value for n in JavaScript.
    For example, I get the below error message saying that n=5 but when I console.log(n) I see that it equals 3??? My code has separated the customers into three arrays in the correct
    order and done everything proper...

    Wrong answer for customers = [3,14,26,28,7,2,33,27,33,6,45,15,14,13,2,6,11,5,30,45,20,31,22,39,31,24,8] and n = 5 - Expected: 114, instead got: 143

  • Damn, these customers are slow af

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

  • Really nice Kata, thanks for it!

  • Loading more items...