The greedy method picks what looks best right now at every step and never looks back. It is fast and easy to write. The hard part is seeing that the choice really does no harm: in some problems the local best leads to the overall best, in others it does not.
fives = tens = 0for bill in bills:if bill == 5:fives += 1elif bill == 10:fives -= 1tens += 1elif tens > 0:tens -= 1fives -= 1else:fives -= 3if fives < 0:return Falsereturn True
Before writing a greedy solution, try to break it: look for a small input on which the choice turns out badly, and if you cannot find one it is probably right. For coins such an input exists: with coins 1, 3 and 4 the rule "take the largest coin" makes 6 with three coins, and two is right.