Ad
  • Custom User Avatar

    What B1ts says doesn't imply changing the order of the list.

    There are two ways to give change for a $100 and one is more efficient than the other.

    Vasya can successfully give change to everyone in this case without changing the order:

                          Queue | Till           | Transaction
    25, 25, 25, 25, 50, 100, 50 |                | - 
        25, 25, 25, 50, 100, 50 | 25             | Take one 25
            25, 25, 50, 100, 50 | 25, 25         | Take one 25
                25, 50, 100, 50 | 25, 25, 25     | Take one 25
                    50, 100, 50 | 25, 25, 25, 25 | Take one 25
                        100, 50 | 25, 25, 25, 50 | Exchange 25 for 50
                             50 | 25, 25, 100    | Exchange 25, 50 for 100
                                | 25, 50, 100    | Exchange 25 for 50
    
  • Custom User Avatar

    Then the Kata is not clear on that. It mentions nothing about being able to shuffle people around. When most people think a line, they think first to last, one after the other.

  • Custom User Avatar

    how do i answer [25, 25, 50, 100] = true ?

    The clerk collects 25 (no change), then another 25, then he receives 50 and gives back 25 change. He now has 1 x 25 and 1 x 50 (exactly 75), which he gives to the next customer and keeps the 100.

    Out of the two options you provided, #1 is correct.

    Does that make sense now?

  • Custom User Avatar

    If the clerk sold a ticket to that person, the clerk would've had enough of change

    No, he wouldn't have enough. The clerk would receive 1 x 100 bill, and he has only 2 x 25 bills to give for change (not enough for 75 needed)

  • Custom User Avatar

    Not a kata issue.

    for the next customer who pays 50

    Don't you think you could use that 50 to give change for 100? The test case is correct.