Ad
  • Custom User Avatar

    What I learn in this kata:

    It's good to be lazy. :D

  • Custom User Avatar

    I don't know what language that you currently use now, but I can give you a hint for Python.

    Google *args python.

    I hope it help!

  • Custom User Avatar

    You don't have to be CS guy to understand this. Let's check the 1st case queue_time([5, 3, 4], 1)

    Imagine [5, 3, 4] is the costumers who want to go to checkout's queue. The 1st person need 5s, the 2nd person need 3s, and the last one need 4s.

    The number 1 is n, which its mean the number of queue.

    This is the scenario:

    1. The 1st person goes into queue 1, since nobody in there.
    2. The 2nd person needs to wait 1st person, because the queue's only 1. After 1st person finish, the 2nd person can go replace him/her.
    3. The 3rd person also needs to wait 2nd person. After 2nd person finish, the 3rd person can procced the checkout.

    The total time? 5 + 3 + 4 = 12.

    Now, let's take a look at 2nd case: [10, 2, 3, 3], 2

    This is the scenario:

    1. The 1st person goes into 1st queue. BUT the 2nd person could go to 2nd queue right? Why? Because it's empty and it will took longer time to checkout if he/she waits the 1s person in the 1st queue.
    2. Now, 2s elapsed, The 2nd person is finished, but the 1st person isn't. So, what the 3rd person do? ...
    3. Now, 5s elapsed, The 3rd person is finish, but the 1st person is still not finish yet. So, what the 4rd person do? ...
    4. Now, 8s elapsed, The 4th person is finish, but the 1st person is still arguing about the fish price (just kidding). But there's no people in waiting list, so the 2nd queue is empty.
    5. Finally, after 10s elapsed, the 1st person is finished.
      Total time? 10s

    How about the 3rd case?

    Well, you can guess actually. By judging the number, you can see that the 1st person and the 3rd person will eventually goes into the same queues.

    So, the total time is 12s.

    I hope this help!