Skip to content

Instantly share code, notes, and snippets.

@kaleidawave
Created August 13, 2019 11:28
Show Gist options
  • Select an option

  • Save kaleidawave/4a5a6f5421d7f0f17977e794c1d49f19 to your computer and use it in GitHub Desktop.

Select an option

Save kaleidawave/4a5a6f5421d7f0f17977e794c1d49f19 to your computer and use it in GitHub Desktop.
The num of coins that are returned in change as mentioned in the first question of this interview https://www.youtube.com/watch?v=HWW-jA6YjHk
coins = [25, 10, 5, 1]
def num__of_coins(cents):
if cents == 0:
return 0
numOfCoins = 0
while cents > 0:
for coin in coins:
if cents >= coin:
cents -= coin
numOfCoins += 1
break
return numOfCoins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment