Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created April 6, 2014 02:19
Show Gist options
  • Save marcoscastro/10000698 to your computer and use it in GitHub Desktop.
Save marcoscastro/10000698 to your computer and use it in GitHub Desktop.
# encoding:utf-8
# problema: http://dojopuzzles.com/problemas/exibe/caixa-eletronico/
def result(saque):
d = {'100':0, '50':0, '20':0, '10':0}
d['100'] = saque//100
saque = saque - d['100']*100
d['50'] = saque//50
saque = saque - d['50']*50
d['20'] = saque//20
saque = saque - d['20']*20
d['10'] = saque//10
saque = saque - d['10']*10
return [d['100'], d['50'], d['20'], d['10']]
def teste(esperado, resultado):
if esperado == resultado:
return True
return False
# teste do valor de saque R$30,00
print(teste([0,0,1,1], result(30)))
# teste do valor de saque R$80,00
print(teste([0,1,1,1], result(80)))
# teste do valor de saque R$280,00
print(teste([2,1,1,1], result(280)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment