#! usr/bin/python3 | |
# Dando o troco | |
# Criado sex 5 abril 2013 | |
# | |
# Dojo PoliGNU | |
# | |
# ,= ,-_-. =. | |
# ((_/)o o(\_)) | |
# `-'(. .)`-' | |
# \_/ | |
# Moedas de 10 e 25 centavos | |
def test_Troco1 (): | |
assert Troco(10) == 1 | |
def test_Troco2 (): | |
assert Troco(15) == 0 | |
def test_Troco3 (): | |
assert Troco(25) == 1 | |
def test_Troco4 (): | |
assert Troco(50) == 2 | |
def test_Troco5 (): | |
assert Troco(100) == 3 | |
def test_Troco6 (): | |
assert Troco(9) == 0 | |
## FUNCAO A SER TESTADA ## | |
def temTroco(valor): | |
aux = valor%25 | |
if aux % 10 == 0: | |
return 1 | |
if valor % 25 != 0 and valor % 10 != 0: | |
return 0 | |
return 1 | |
def Troco (valor): | |
# if temTroco(valor) == 0: | |
# return 0 | |
# elif valor % 10 == 0 and valor % 50==0: | |
# return 1 | |
# else: | |
# return 1 | |
maxN = valor//25 | |
cont = 0 | |
for n in range(0,maxN + 1): | |
restante = valor - n*25 | |
if restante%10 == 0: | |
cont += 1 | |
return cont | |
# RaciocÃnio ao fim do Dojo: | |
# | |
# conts = 0 | |
# if valor%10 == 0 or valor%25 == 0: | |
# for x in range(0,valor/10) | |
# for y in range(0,valor/25) | |
# if valor == 10x + 25y: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment