Beispiel #1
0
def get_change(value):

    value = value * 100
    result = {}
    for i in COINAGE_LIST:
        nom = i[1]
        count = value // nom
        if count:
            value = value % nom
            key = list(COINAGE.keys())[list(COINAGE.values()).index(nom)]
            result[key] = int(count)
    return result
Beispiel #2
0
def get_change(amount):
    result = {}
    amount *= 100
    for coin_name, coin_value in sorted(COINAGE.items(),
                                        key=lambda pair: -pair[1]):
        count = int(amount // coin_value)
        result[coin_name] = count
        amount -= count * coin_value
    return result
Beispiel #3
0
def get_change(valuee):
    result = {}
    new_value = valuee * 100
    for note, value in sorted(COINAGE.items(), reverse=True, key=lambda i: i[1]):
        count = int(new_value / value)
        if count:
            result[note] = count
        new_value -= count * value
    return result
Beispiel #4
0
def get_change(amount):
    result = {}
    xxx = amount * 100
    for coin_name, coin_value in sorted(COINAGE.items(), key=lambda pair: -pair[1]):
        count = int(xxx / coin_value)
        if count:
            result[coin_name] = count
        xxx -= count * coin_value
    return result
Beispiel #5
0
def get_change(amount):
    bills = {}
    amount *= 100
    for note, cost in sorted(COINAGE.items(), key=lambda i: -i[1]):
        number = int(amount // cost)
        bills[note] = number
        amount -= cost * number

    return bills
Beispiel #6
0
def get_change(mon):

    mon *= 100
    res = {}
    for note, val in sorted(COINAGE.items(), key=lambda pair: -pair[1]):
        count = int(mon / val)
        if count:
            res[note] = count
        mon -= count * val
    return res
Beispiel #7
0
from project.consts import COINAGE

COINAGE = list(reversed(list(COINAGE.items())))


def get_change(money):
    money *= 100
    result = {}
    for i in COINAGE:
        if money < i[1]:
            pass
        elif money >= i[1]:
            result[i[0]] = 0
            while money >= i[1]:
                money -= i[1]
                result[i[0]] += 1
    return result
Beispiel #8
0
from project.consts import COINAGE

_coinage_reversed = {_value: _coin for _coin, _value in COINAGE.items()}


def get_change(amount):
    rest = int(amount * 100)
    coinage = {}

    while rest:
        nominal, name = max((value, name)
                            for value, name in _coinage_reversed.items()
                            if value <= rest)
        items, rest = divmod(rest, nominal)
        coinage[name] = items

    return coinage
Beispiel #9
0
from project.consts import COINAGE

COINAGE_LIST = sorted(COINAGE.items(), key=lambda x: x[1], reverse=True)


def get_change(value):

    value = value * 100
    result = {}
    for i in COINAGE_LIST:
        nom = i[1]
        count = value // nom
        if count:
            value = value % nom
            key = list(COINAGE.keys())[list(COINAGE.values()).index(nom)]
            result[key] = int(count)
    return result