Skip to content

Instantly share code, notes, and snippets.

@n4sm
Created May 4, 2020 07:15
Show Gist options
  • Save n4sm/f6c9fbb039a19b8738b672d4648f7f62 to your computer and use it in GitHub Desktop.
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
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