Skip to content

Instantly share code, notes, and snippets.

def calculate_coins(c, s):
#sort the coins
c = sorted(c)
# remove the coins with values bigger than s
c = [ci for ci in filter(lambda cv: cv<=s, c)]
# sentinel value to represent that one coin sum is not possible. We can use s + 1 as sentinel value to represent
# that case. Mininum value of a coin is 1 so more than s coins can not make a sum of s
sentinel = s+1