Created
May 4, 2020 07:15
-
-
Save n4sm/f6c9fbb039a19b8738b672d4648f7f62 to your computer and use it in GitHub Desktop.
Just a program which from a list of coins and a max value returns a list of the coins used
This file contains 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 rendu_S(syst_coins : list, max_val : int) -> list: | |
coins_used = [] | |
syst_coins_sorted = sorted(syst_coins, reverse=True) | |
i = 0x0 | |
while max_val > 0x0: | |
if syst_coins_sorted[i] > max_val: | |
i += 1 | |
continue | |
max_val = max_val - syst_coins_sorted[i] | |
coins_used.append(syst_coins_sorted[i]) | |
return coins_used |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment