This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer