Ad
  • Custom User Avatar

    Yeah! I was wondering if this could be done without having to destructure the pair... learning so much from everyone here :)

  • Default User Avatar

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

  • Custom User Avatar

    'First transaction thru transaction four: add $25 to the register (total is $100).
    Fifth transaction: make change for $25 ($75 in register).'
    You're making change for the customers, but you're forgetting to take their initial bill. In essence, you're giving all of your money away. Your total value should increase by $25 because that's what each customer is paying.

  • Custom User Avatar

    The test case is correct, it's about the exact number of each bill you have, not the total.
    After customer 5, you have five 25s. Once you get that 100, you need to give back $75 (three 25s).
    You're left with one 100 and two 25s. When you get that second 100, you can't give him back $75 with two 25s and one 100.
    Also on step 6, you're subtracting 75, but only adding 25.. If you have 125 and he gives you 100, you're left with 225. THEN you give him 75, and finally you'll have 150, not 75

  • Default User Avatar

    Test case: [ 25, 25, 25, 25, 25, 100, 100 ]

    1. bank - 25
    2. bank - 50
    3. bank - 75
    4. bank - 100
    5. bank - 125
    6. bank = 125 - 75 = 50, 50 + 25 = 75
    7. 100 - 75
      Test says - 'NO', but I think - 'YES'
      Am I wrong ?
  • Default User Avatar

    I like your oneliner)
    On the other hand - I think it is bad practice to rescue from all exceptions.
    Don't you think so ?