Ad
  • Custom User Avatar

    This code has an issue in that it can create both false positives and false negatives as it has no understanding of how making change actually works.

    [25,50] is supposed return "YES" because when the person with the 50 comes in, the clerk has $25 in change they can give and that's exactly how much change is needed. However, the comparison listed under any() will say "Is 50 greater than 25? Yes, so I must be true" and thus tells elif to execute its code, which returns "NO".

    For [25,25,50,50,100], on the other hand, it should return "NO" because by the time you get to the person with the $100 bill, you've given out all of your $25 bills already so you can't possibly give change. However, any will check "Is 100 greater than 150? No. Since there's nothing that meets the condition I'm looking for, then I must be false" and tells elif that it can skip over its code, and the code then executes the return for "YES".