Ad
  • Default User Avatar

    The queue you've written is correct, but each clone and the original drinks only one can, so all the "sheldons" together would drink 4 cans.

  • Default User Avatar

    I am really sorry. The issue was in my solution.

  • Default User Avatar

    The tests don't use the order, or the specific value, of thread IDs. They just use thread IDs to identify how many threads were used, and which numbers were grouped together in the same thread. The only thing it relies on is that each thread has a unique ID, which is guaranteed.

  • Default User Avatar

    The tests pass randomly as the order of threads depends on their id which can vary

  • Default User Avatar

    It's not clear for me what happens on the 3rd cycle? All of them drink 4 cans of cola or they continue drinking 2 cans at once? Is this a correct queue?

    Sheldon, Leonard, Penny, Rajesh, Howard,
    Sheldon, Sheldon, Leonard, Leonard, Penny, Penny, Rajesh, Rajesh, Howard, Howard,
    Sheldon, Sheldon, Sheldon, Sheldon, Leonard, Leonard, Leonard, Leonard, Penny, Penny, Penny, Penny, ...

  • Default User Avatar

    If I am not mistaken // operator is in Python since 2.2... I found this in PEP 238

    Here are the changes 2.2 introduces:

    A new operator, //, is the floor division operator. (Yes, we know it looks like C++'s comment symbol.) // always performs floor division no matter what the types of its operands are, so 1 // 2 is 0 and 1.0 // 2.0 is also 0.0.
    
    // is always available in Python 2.2; you don't need to enable it using a __future__ statement. 
    
  • Custom User Avatar

    thanks for helping me improve my code! :) does the // mean that python3 is used?

  • Default User Avatar

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