Ad
  • Custom User Avatar

    It's always big dollar bill first, because if you give smaller dollar bills first at any point you'll always have potential oppotunity to run out of change for cases you can avoid getting into that situation.

    Try thinking of a few scenarios and work it out in your head (or by pen and paper) ;-)

  • Custom User Avatar

    It's common sense in this kind of problems (even in real life), you'll always try to get rid of the higher value bills first, to not run out of the small ones.

  • Custom User Avatar

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

  • Custom User Avatar

    Breaking bills is not something you can do anywhere, it's implicit.
    If it were possible, the problem would be trivial and you could always give them their change (given there is enough in the cash register).

  • Custom User Avatar

    For this test cases fail:

    test.assert_equals(tickets([25, 25, 50]), "YES")
    test.assert_equals(tickets([25, 100]), "NO")
    test.assert_equals(tickets([25, 25, 50, 100, 25, 25]), "YES")
    test.assert_equals(tickets([25, 25, 50, 100, 25, 50]), "YES")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25,25,25,25,25,25,25,100,100,100,100]), "YES")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25,25,25,25,25,25,100,100,100,100]), "NO")
    test.assert_equals(tickets([100,100,100,100, 25, 25, 25, 25, 25, 25,25,25,25,25,25,25]), "YES")
    test.assert_equals(tickets([100,100,100, 25, 25, 25, 25, 25, 25,25,25,25,25,25,100]), "NO")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25,25,25,25,25,25,25,50,50,50,50]), "YES")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25,25,25,25,25,25,50,50,50,50,100]), "YES")
    test.assert_equals(tickets([25, 25, 50]), "YES")
    test.assert_equals(tickets([25, 100]), "NO")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25, 25, 25, 25, 25]), "YES")
    test.assert_equals(tickets([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]), "NO")
    test.assert_equals(tickets([100, 100, 100, 100, 100, 100, 100, 100, 100, 100]), "NO")
    test.assert_equals(tickets([25, 25, 25, 25, 50, 100, 50]), "YES")
    test.assert_equals(tickets([50, 100,100]), "NO")
    test.assert_equals(tickets([25, 25, 100]), "NO")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 25, 25, 50, 50, 50, 100, 100, 100, 100]), "NO")
    test.assert_equals(tickets([25, 25, 50, 50, 100]), "NO")
    test.assert_equals(tickets([25, 50, 50]), "NO")
    test.assert_equals(tickets([25, 25, 25, 100]), "YES")
    test.assert_equals(tickets([25, 50, 25, 100]), "YES")
    test.assert_equals(tickets([25, 25, 25, 25, 25, 100, 100]), "NO")

    Supposily in the last one, but if i put the last one alone it does not fail

  • Custom User Avatar