Монети

Краен срок
08.03.2013 23:59

Срокът за предаване на решения е отминал

Да се напише функция calculate_coins(sum), която приема число с плаваща запетая и връща списък с монети. Целта е сумата да се представи с минималния брой монети.

Представете си, че сте касиерка във Фантастико и трябва да върнете по възможно най-малко неудобния начин ресто, съставено само от монети. Очевидно - минималният брой монети е за предпочитане.

Пример:

>>> calculate_coins(0.53)
{1: 1, 2: 1, 100: 0, 5: 0, 10: 0, 50: 1, 20: 0}
>>> calculate_coins(8.94)
{1: 0, 2: 2, 100: 8, 5: 0, 10: 0, 50: 1, 20: 2}

Не мислете за каквито и да е проверки дали входът е валиден. Няма нужда вашият код да се държи адекватно при вход (-42.0, 3.1415).

Решения

Георги Ангелов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Ангелов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
""" Return the smallest possible set of coins with a sum of `sum`. """
sum = int(sum * 100)
coin_numbers = dict()
for coin in COINS:
coin_numbers[coin] = sum // coin
sum %= coin
return coin_numbers
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-15ckxtc/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Орлин Христов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Орлин Христов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum_):
sum_ = int(100 * sum_)
coin_distribution = {}
for coin in COINS:
coin_distribution[coin] = sum_ // coin
sum_ %= coin
return coin_distribution
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-nsfx3f/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Станислав Гатев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Станислав Гатев
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(money):
money_in_coins = int(money * 100)
change = {}
for coin in COINS:
change[coin] = money_in_coins // coin
money_in_coins %= coin
return change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1ycvj28/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Щилиян Харбов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Щилиян Харбов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
sum = int(sum * 100)
change = {}
for coin in COINS:
if sum // coin:
change[coin] = sum // coin
sum %= coin
else:
change[coin] = 0
return change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1dzufpa/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Ралица Маркова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Ралица Маркова
def calculate_coins(sum):
coins = (100, 50, 20, 10, 5, 2, 1)
calculated_coins = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
sum *= 100
for coin in coins:
while coin <= sum:
calculated_coins[coin] += 1
sum -= coin
return calculated_coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1sfg21n/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Йордан Джамбазов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Йордан Джамбазов
"""Solution for Challenge 1. The module contains a function, that shows what
is the most optimal way to return coins."""
def calculate_coins(sum):
"""Find the best way to return coins to customer.
Keyword arguments:
sum -- the amount of money that need to be returned in coins.
Returns a dictionary, where the keys are the coins and the
values are the numbers of them.
"""
sum_in_coins = sum * 100
coins = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
while sum_in_coins > 0.0:
for coin in sorted(coins.keys(), reverse=True):
if coin <= sum_in_coins:
biggest_possible_coin = coin
break
coins[biggest_possible_coin] += 1
sum_in_coins -= biggest_possible_coin
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-111h5ok/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
AssertionError: {1: 0, 50: 0, 20: 0, 5: 0, 100: 0, 10: 1, 2: 3} != {1: 0, 2: 2, 20: 0, 5: 0, 100: 0, 10: 1, 50: 0}
- {1: 0, 2: 3, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0}
?           ^

+ {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0}
?           ^


----------------------------------------------------------------------
Ran 4 tests in 0.004s

FAILED (failures=1)
Филарета Йорданова
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Филарета Йорданова
MIN_COINS = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
COINS = [50, 20, 10, 5, 2, 1]
def calculate_coins(cash):
splat_number = (str(cash)).split('.')
integer, fraction = int(splat_number[0]), int(splat_number[1])
if (splat_number[1] in ['1', '2', '5']):
fraction *= 10
MIN_COINS[100] = integer
for coin in COINS:
MIN_COINS[coin] = fraction // coin
fraction = fraction % coin
return MIN_COINS
.E.E
======================================================================
ERROR: test_one (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-mhmzrs/test.py", line 22, in test_one
    self.assertEqual(calculate_coins(1), {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 1})
  File "/tmp/d20130325-7534-mhmzrs/solution.py", line 7, in calculate_coins
    integer, fraction = int(splat_number[0]), int(splat_number[1])
IndexError: list index out of range

======================================================================
ERROR: test_zero (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-mhmzrs/test.py", line 10, in test_zero
    self.assertEqual(calculate_coins(0), self.zero_dict)
  File "/tmp/d20130325-7534-mhmzrs/solution.py", line 7, in calculate_coins
    integer, fraction = int(splat_number[0]), int(splat_number[1])
IndexError: list index out of range

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (errors=2)
Илия Тобов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Илия Тобов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
change = {1: 0, 2: 0, 5: 0, 10: 0,
20: 0, 50: 0, 100: 0}
sum *= 100
for coin in COINS:
if sum/coin > 0 and sum is not 0:
change[coin] = sum//coin
sum -= coin*change[coin]
return change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1xc133r/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1.0, 2: 0.0, 20: 0.0, 5: 1.0, 100: 0.0, 10: 0.0, 50: 1.0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1.0, 2: 0.0, 5: 1.0, 10: 0.0, 20: 0.0, 50: 1.0, 100: 0.0}
?     --      ^^^      --      --       --        --       --

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?           ^


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Николай Манолов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Николай Манолов
def calculate_coins(amount):
change = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
coins = [100, 50, 20, 10, 5, 2, 1]
balance = 0
amount = amount * 100
for coin in coins:
while balance + coin <= amount:
balance += coin
change[coin] += 1
return change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-23bsge/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Николай Хубанов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Николай Хубанов
def calculate_coins(sum):
COINS_NOMINAL = (100, 50, 20, 10, 5, 2, 1)
result = {}
sum = int(sum * 100)
for nominal in COINS_NOMINAL:
result[nominal] = sum // nominal
sum = sum % nominal
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-1vfvt52/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Георги Горанов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Горанов
coins = {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
def calculate_coins(sum):
left_sum = int(sum*100)
for coin in (100, 50, 20, 10, 5, 2, 1):
coins[coin] = int((left_sum - left_sum % coin)/coin)
left_sum = int(left_sum - coin * coins[coin])
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-189xkw2/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Илия Ватахов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Илия Ватахов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(money):
result = {}
money *= 100
for coin in COINS:
result[coin] = (int)(money / coin)
money = money % coin
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-16bmgnf/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Симеон Попов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Симеон Попов
def calculate_coins(sum):
sum = round(sum*100)
lev = sum//100
sum = sum-lev*100
petdeset = sum//50
sum = sum-petdeset*50
dvadeset = sum//20
sum = sum-dvadeset*20
deset = sum//10
sum = sum-deset*10
pet = sum//5
sum = sum-pet*5
dve = sum//2
sum = sum-dve*2
edna = sum/1
sum = sum-edna*1
return {1: round(edna),
2: round(dve),
5: round(pet),
10: round(deset),
20: round(dvadeset),
50: round(petdeset),
100: round(lev)}
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Виктория Христова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Виктория Христова
def calculate(sum, result, money):
if sum == 0:
return result
nominal = money.pop()
result[nominal] = sum // nominal
return calculate(sum % nominal, result, money)
def calculate_coins(sum):
nominals = [1, 2, 5, 10, 20, 50, 100]
empty = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
return calculate(sum * 100, empty, nominals)
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-w9ec0q/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 12, in calculate_coins
    return calculate(sum * 100, empty, nominals)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 6, in calculate
    return calculate(sum % nominal, result, money)
  File "/tmp/d20130403-12177-w9ec0q/solution.py", line 4, in calculate
    nominal = money.pop()
IndexError: pop from empty list

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (errors=1)
Иван Георгиев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Георгиев
import math
COINS = [50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
result = {}
result[100] = math.trunc(sum)
remainder = round(math.modf(sum)[0] * 100)
for coin in COINS:
result[coin] = round(math.trunc(remainder / coin))
remainder = round(remainder - result[coin] * coin)
return result
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Нели Хатева
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Нели Хатева
def calculate_coins(sum):
representation_coins = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
COINS = (100, 50, 20, 10, 5, 2, 1)
COINS = iter(COINS)
coin = next(COINS)
sum *= 100
while sum > 0:
if sum >= coin:
sum -= coin
representation_coins[coin] += 1
else:
coin = next(COINS)
return representation_coins
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-sidf72/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
  File "/tmp/d20130403-12177-sidf72/solution.py", line 12, in calculate_coins
    coin = next(COINS)
StopIteration

----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (errors=1)
Емил Гелев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Емил Гелев
coins = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
value = sum * 100
res = []
for coin in coins:
res.append((coin, int(value // coin)))
value %= coin
return dict(res)
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-dteqfi/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Александър Димитров
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Александър Димитров
COINS = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
sum_left = int(sum * 100)
result = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
for coin in COINS:
if sum_left >= coin:
coin_count = sum_left // coin
sum_left -= coin * coin_count
result[coin] = coin_count
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-k9d61o/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Стела Живкова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Стела Живкова
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
num_coins = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
sum = sum * 100
counter = 0
while sum != 0:
num_coins[COINS[counter]] = int(sum // COINS[counter])
sum = sum % COINS[counter]
counter = counter + 1
return num_coins
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1frnchg/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
  File "/tmp/d20130403-12177-1frnchg/solution.py", line 9, in calculate_coins
    num_coins[COINS[counter]] = int(sum // COINS[counter])
IndexError: tuple index out of range

----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (errors=1)
Весела Бандова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Весела Бандова
import math
def calculate_coins(sum):
coins_count = {}
tuple_of_coins = 100, 50, 20, 10, 5, 2, 1
sum = math.ceil(sum*100)
for i in tuple_of_coins:
coins_count[i] = int(sum/i)
sum -= coins_count[i]*i
return coins_count
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-bd6vgp/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
AssertionError: {1: 0, 50: 0, 20: 0, 5: 1, 100: 0, 10: 1, 2: 0} != {1: 0, 2: 2, 20: 0, 5: 0, 100: 0, 10: 1, 50: 0}
- {1: 0, 2: 0, 5: 1, 10: 1, 20: 0, 50: 0, 100: 0}
?             ------

+ {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0}
?           ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Милан Миланов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Милан Миланов
def calculate_coins(sum):
coins_amounts = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
sum *= 100
for coin_amount in sorted(coins_amounts.keys(), reverse = True):
coins_amounts[coin_amount] = sum // coin_amount
sum -= coins_amounts[coin_amount] * coin_amount
return coins_amounts
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-169v2o8/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1.0, 50: 1.0, 20: 0.0, 5: 1.0, 100: 0.0, 10: 0.0, 2: 0.0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1.0, 2: 0.0, 5: 1.0, 10: 0.0, 20: 0.0, 50: 1.0, 100: 0.0}
?     --      ^^^      --      --       --        --       --

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?           ^


----------------------------------------------------------------------
Ran 4 tests in 0.004s

FAILED (failures=1)
Добринка Табакова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Добринка Табакова
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
sum_coins = int(sum*100)
result = {c: 0 for c in COINS}
i = 0
while(sum_coins > 0):
num = int(sum_coins/COINS[i])
result[COINS[i]] = num
sum_coins = sum_coins%COINS[i]
i = i + 1
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-1rkkla0/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Александър Петков
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Александър Петков
RESULT = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
COINS = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
for i in COINS:
while sum // (i / 100) > 0:
RESULT[i] += 1
sum = round(sum - (i / 100), 2)
return RESULT
FFFF
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-dithgs/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 0, 2: 3, 100: 0, 5: 1, 20: 0, 10: 1, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 0, 2: 3, 5: 1, 10: 1, 20: 0, 50: 1, 100: 0}
?           ^            ^

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?           ^            ^


======================================================================
FAIL: test_one (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-dithgs/test.py", line 16, in test_one
    self.assertEqual(calculate_coins(0.01), {1: 1, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0})
AssertionError: {1: 1, 2: 3, 100: 0, 5: 1, 20: 0, 10: 1, 50: 1} != {1: 1, 2: 0, 20: 0, 5: 0, 100: 0, 10: 0, 50: 0}
- {1: 1, 2: 3, 5: 1, 10: 1, 20: 0, 50: 1, 100: 0}
?           ^     ^      ^             ^

+ {1: 1, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
?           ^     ^      ^             ^


======================================================================
FAIL: test_one_of_each (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-dithgs/test.py", line 13, in test_one_of_each
    self.assertEqual(calculate_coins(1.88), {x:1 for x in self.zero_dict})
AssertionError: {1: 2, 2: 4, 100: 1, 5: 2, 20: 1, 10: 2, 50: 2} != {1: 1, 2: 1, 20: 1, 5: 1, 100: 1, 10: 1, 50: 1}
- {1: 2, 2: 4, 5: 2, 10: 2, 20: 1, 50: 2, 100: 1}
?     ^     ^     ^      ^             ^

+ {1: 1, 2: 1, 5: 1, 10: 1, 20: 1, 50: 1, 100: 1}
?     ^     ^     ^      ^             ^


======================================================================
FAIL: test_zero (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-dithgs/test.py", line 10, in test_zero
    self.assertEqual(calculate_coins(0), self.zero_dict)
AssertionError: {1: 2, 2: 4, 100: 1, 5: 2, 20: 1, 10: 2, 50: 2} != {1: 0, 2: 0, 20: 0, 5: 0, 100: 0, 10: 0, 50: 0}
- {1: 2, 2: 4, 5: 2, 10: 2, 20: 1, 50: 2, 100: 1}
?     ^     ^     ^      ^      ^      ^       ^

+ {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
?     ^     ^     ^      ^      ^      ^       ^


----------------------------------------------------------------------
Ran 4 tests in 0.009s

FAILED (failures=4)
Марина Узунова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Марина Узунова
def calculate_coins(sum):
s=sum*100
l = {}
ll = [100,50,20,10,5,2,1]
for i in range(0, 7):
l[ll[i]]=s//ll[i]
s=s%ll[i]
return l
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-252m07/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1.0, 50: 1.0, 20: 0.0, 5: 1.0, 100: 0.0, 10: 0.0, 2: 0.0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1.0, 2: 0.0, 5: 1.0, 10: 0.0, 20: 0.0, 50: 1.0, 100: 0.0}
?     --      ^^^      --      --       --        --       --

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?           ^


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Десислава Добрева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Десислава Добрева
COINS1=[100,50,20,10,5,2,1]
def calculate_coins(suma):
COINS={100:0,50:0,20:0,10:0,5:0,2:0,1:0}
suma = round(suma*100)
while suma > 0:
for c in COINS1:
if suma >= c:
COINS[c] += 1
suma -= c
break
return COINS
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Мартин Костов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Мартин Костов
def calculate_coins(sum):
sum = int(round(sum * 100))
change = {}
coins = (100, 50, 20, 10, 5, 2, 1)
for coin in coins:
change[coin] = int(sum / coin)
sum %= coin
return change
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Христо Хърсев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Христо Хърсев
import math
def calculate_coins(sum):
coins = [100, 50, 20, 10, 5, 2, 1]
change = {}
for coin in coins:
change.update({coin: math.floor(sum/(coin/100))})
sum = round(sum % (coin/100), 2)
return(change)
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Илия Ячев
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Илия Ячев
COIN_SIZES = [100, 50, 20, 10, 5, 2, 1]
def calsulate_coins(sum):
sum = int(sum * 100)
coin_count = []
for coin_size in COIN_SIZES:
coin_count.append(sum / coin_size)
sum %= coin_size
return {size : coin_count[i] for i, size in enumerate(COIN_SIZES)}
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130403-12177-1vvy1sp/test.py", line 2, in <module>
    from solution import calculate_coins
Данаил Димитров
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Данаил Димитров
def calculate_coins(sum):
COINS = [1, 0.50, 0.20, 0.10, 0.05, 0.02, 0.01]
COINSDICT = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
for coin in COINS[:7]:
while sum >= coin:
sum -= coin
COINSDICT[coin*100] = COINSDICT[coin*100] + 1
return COINSDICT
F.F.
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-1ryl73u/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


======================================================================
FAIL: test_one_of_each (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-1ryl73u/test.py", line 13, in test_one_of_each
    self.assertEqual(calculate_coins(1.88), {x:1 for x in self.zero_dict})
AssertionError: {1: 0, 2: 1, 100: 1, 5: 1, 20: 1, 10: 1, 50: 1} != {1: 1, 2: 1, 20: 1, 5: 1, 100: 1, 10: 1, 50: 1}
- {1: 0, 2: 1, 5: 1, 10: 1, 20: 1, 50: 1, 100: 1}
?     ^

+ {1: 1, 2: 1, 5: 1, 10: 1, 20: 1, 50: 1, 100: 1}
?     ^


----------------------------------------------------------------------
Ran 4 tests in 0.005s

FAILED (failures=2)
Петър Добрев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Петър Добрев
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
resto = {}
sum *= 100
for n in COINS:
tmp = int(sum/n)
resto[n] = tmp
sum -= tmp*n
return resto
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-1gag8v6/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Александър Пенев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Александър Пенев
def calculate_coins(sum):
coins = (100, 50, 20, 10, 5, 2, 1)
coins_count = {}
sum = sum * 100
for coin in coins:
whole_part = sum // coin
if not coins_count.get(coin) is None:
coins_count[coin] += whole_part
else:
coins_count[coin] = int(whole_part)
sum -= coin * whole_part
return coins_count
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-138dck4/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Иван Боршуков
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Иван Боршуков
COINS = [1, 2, 100, 5, 10, 50, 20]
def calculate_coins(sum):
sum *= 100
change = {coin: 0 for coin in COINS}
while sum != 0:
coin = max([x for x in COINS if sum-x >= 0])
sum -= coin
change[coin] += 1
return change
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-lkj1ux/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
  File "/tmp/d20130403-12177-lkj1ux/solution.py", line 6, in calculate_coins
    coin = max([x for x in COINS if sum-x >= 0])
ValueError: max() arg is an empty sequence

----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (errors=1)
Иван Капукаранов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Иван Капукаранов
def calculate_coins(sum):
coins = (100, 50, 20, 10, 5, 2, 1)
resto = {coin: 0 for coin in coins}
b = 0
c = 0
while sum > 0.99:
b += 1
sum -= 1
c = int(sum * 10)
d = int(((sum * 100) + 0.00099) % 10)
big_coins = ({}, {10: 1}, {20: 1}, {20: 1, 10: 1},
{20: 2}, {50: 1}, {50: 1, 10: 1}, {50: 1, 20: 1},
{50: 1, 20: 1, 10: 1}, {50: 1, 20: 2})
small_coins = ({}, {1: 1}, {2: 1}, {2: 1, 1: 1},
{2: 2}, {5: 1}, {5: 1, 1: 1}, {5: 1, 2: 1},
{5: 1, 2: 1, 1: 1}, {5: 1, 2: 2})
resto.update(big_coins[c])
resto.update({100: b})
resto.update(small_coins[d])
return resto
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Кристиян Якимов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Кристиян Якимов
def calculate_coins(sum):
sum = sum * 100
coins = {100:0, 50:0, 20:0, 10:0, 5:0, 2:0, 1:0}
next_coin = {100:50, 50:20, 20:10, 10:5, 5:2}
current_coin = 100
number_coins = 0
while sum > 1:
if int(sum / current_coin) != 0:
sum = sum - current_coin
number_coins = number_coins + 1
else:
coins[current_coin] = number_coins
current_coin = next_coin[current_coin]
number_coins = 0
coins[current_coin] = number_coins
if sum == 1:
coins[1] = 1
return coins
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-rfi0bm/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
  File "/tmp/d20130323-7534-rfi0bm/solution.py", line 13, in calculate_coins
    current_coin = next_coin[current_coin]
KeyError: 2

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (errors=1)
Мария Митева
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Мария Митева
COINS_NOMINAL_VALUE = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
coins_count = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
int_sum = round(sum*100)
index = 0
while int_sum > 0:
if COINS_NOMINAL_VALUE[index] <= int_sum:
int_sum -= COINS_NOMINAL_VALUE[index]
coins_count[COINS_NOMINAL_VALUE[index]] += 1
else:
index += 1
return coins_count
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Радослав Платиканов
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Радослав Платиканов
COIN_TYPES = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
result = dict()
sum_cents = int(round(sum * 100))
for coin in COIN_TYPES:
result[coin] = sum_cents // coin
sum_cents -= result[coin] * coin
return result
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Здравко Георгиев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Здравко Георгиев
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(amount):
coins_hash = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
change_count = 0
amount *= 100
for coin in COINS:
count = 0
while change_count + coin <= amount:
change_count = change_count + coin
count += 1
coins_hash[coin] = count
return coins_hash
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-argjc3/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Георги Шопов
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Георги Шопов
from math import ceil
COIN_SAMPLE = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
sum = ceil(sum * 100) # Otherwise: 2.03 * 100 returns 202.9
least_coin_change = {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
for coin_value in COIN_SAMPLE:
if sum > 0:
least_coin_change[coin_value] = int(sum / coin_value)
sum -= least_coin_change[coin_value] * coin_value
else:
return least_coin_change
return least_coin_change
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-19hcy4s/test.py", line 2, in <module>
    from homework import calculate_coins
Свилен Андонов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Свилен Андонов
COINS = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(value):
value *= 100
result = {}
for key in COINS:
result[key] = 0
while key <= value:
value -= key
result[key] = result[key] + 1
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-uzhnwf/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Михаил Петков
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Михаил Петков
coins = {}
def calculate_coins(sum):
sum = sum * 100
for i in (100, 50, 20, 10, 5, 2, 1):
coins[i] = int(sum / i)
sum = sum - coins[i] * i
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1sfin7p/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Христо Мохамед
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Христо Мохамед
#!/usr/bin/env python
def calculate_coins(coins):
values = [100, 50, 20, 10, 5, 2, 1]
coins = int(coins*100)
change = []
for i in range(7):
change.append(0)
while coins - values[i] >= 0:
change[i] = change[i] + 1
coins -= values[i]
change_dict = {}
change_dict[1] = change[6]
change_dict[2] = change[5]
change_dict[100] = change[0]
change_dict[5] = change[4]
change_dict[10] = change[3]
change_dict[50] = change[1]
change_dict[20] = change[2]
return change_dict
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-3o42gx/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Ахмед Садък
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Ахмед Садък
DICTIONARY = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
SAT = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(number):
coins = dict(DICTIONARY)
number *= 100
for i in SAT:
while number >= i:
coins[i] += 1
number -= i
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-1lsuipa/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Ния Дончева
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Ния Дончева
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
sum *= 100
calculated_change = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
for coin in COINS:
while coin <= sum:
calculated_change[coin] += 1
sum -= coin
return calculated_change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1o8l7g9/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Рейхан Садък
  • Некоректно
  • 0 успешни тест(а)
  • 4 неуспешни тест(а)
Рейхан Садък
COIN_VALUES = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(coinsValue):
result_dict = {}
coinsValueInteger = int(coinsValue* 100)
for i in COIN_VALUES:
result_dict[i] = coinsValueInteger // i
coinsValueInteger = coinsValueInteger % i
print(result_dict)
F
Stdout:
{1: 0, 50: 0, 20: 0, 5: 0, 100: 0, 10: 1, 2: 2}
F
Stdout:
{1: 1, 50: 0, 20: 0, 5: 0, 100: 0, 10: 0, 2: 0}
F
Stdout:
{1: 1, 50: 1, 20: 1, 5: 1, 100: 1, 10: 1, 2: 1}
F
Stdout:
{1: 0, 50: 0, 20: 0, 5: 0, 100: 0, 10: 0, 2: 0}

======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-159cc3u/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
AssertionError: None != {1: 0, 2: 2, 20: 0, 5: 0, 100: 0, 10: 1, 50: 0}

Stdout:
{1: 0, 50: 0, 20: 0, 5: 0, 100: 0, 10: 1, 2: 2}

======================================================================
FAIL: test_one (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-159cc3u/test.py", line 16, in test_one
    self.assertEqual(calculate_coins(0.01), {1: 1, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0})
AssertionError: None != {1: 1, 2: 0, 20: 0, 5: 0, 100: 0, 10: 0, 50: 0}

Stdout:
{1: 1, 50: 0, 20: 0, 5: 0, 100: 0, 10: 0, 2: 0}

======================================================================
FAIL: test_one_of_each (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-159cc3u/test.py", line 13, in test_one_of_each
    self.assertEqual(calculate_coins(1.88), {x:1 for x in self.zero_dict})
AssertionError: None != {1: 1, 2: 1, 20: 1, 5: 1, 100: 1, 10: 1, 50: 1}

Stdout:
{1: 1, 50: 1, 20: 1, 5: 1, 100: 1, 10: 1, 2: 1}

======================================================================
FAIL: test_zero (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-159cc3u/test.py", line 10, in test_zero
    self.assertEqual(calculate_coins(0), self.zero_dict)
AssertionError: None != {1: 0, 2: 0, 20: 0, 5: 0, 100: 0, 10: 0, 50: 0}

Stdout:
{1: 0, 50: 0, 20: 0, 5: 0, 100: 0, 10: 0, 2: 0}

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (failures=4)
Светлана Величкова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Светлана Величкова
def calculate_coins(sum):
coins = {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
sum *= 100
for quantity in [100, 50, 20, 10, 5, 2, 1]:
coins[quantity] = (int)(sum // quantity)
sum = sum % quantity
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-widvkq/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Пламена Петрова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Пламена Петрова
def calculate_coins(sum):
coins = [100, 50, 20, 10, 5, 2, 1]
Kasa = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
sum = sum * 100
for coin in coins:
if (int(sum / coin) != 0):
Kasa[coin] = Kasa[coin] + int(sum/coin)
sum = sum - int(sum/coin) * coin
return Kasa
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-16al867/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Момчил Джамбазов
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Момчил Джамбазов
def calculate_coins(sum):
sum = sum * 100
nominals = [100, 50, 20, 10, 5, 2, 1]
coins = {nominal: 0 for nominal in nominals}
while sum > 0:
for nominal in nominals:
if nominal <= sum:
sum -= nominal
coins[nominal] += 1
break
return coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-1qawthf/test.py", line 2, in <module>
    from homework import calculate_coins
Красимира Божанова
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Красимира Божанова
def calculate_coins(sum):
sum *= 100
coins = {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
for coin in sorted(coins.keys())[::-1]:
while (sum - coin >= 0):
coins[coin] += 1
sum -= coin
return coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-1uexu61/test.py", line 2, in <module>
    from homework import calculate_coins
Станимир Николов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Станимир Николов
def calculate_coins(sum):
coins = (100, 50, 20, 10, 5, 2, 1)
result = {}
sum = sum*100
for coin in coins:
number_of_coins = int(sum/coin)
sum = sum - number_of_coins*coin
result[coin] = number_of_coins
return result
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-96qya8/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Вероника Стоилова
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Вероника Стоилова
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
result = {}
sum = sum*100
for coin_type in COINS:
result[coin_type] = int(sum/coin_type)
sum = sum - (result[coin_type] * coin_type)
return result
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-hbx09a/test.py", line 2, in <module>
    from homework import calculate_coins
Беатрис Бонева
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Беатрис Бонева
def calculate_coins(sum):
sum = int(sum * 100)
coins = {
1: 0,
2: 0,
100: 0,
5: 0,
10: 0,
50: 0,
20: 0}
while sum > 0:
for x in sorted(coins.keys(), reverse=True):
if x <= sum:
coins[x] += 1
sum -= x
break
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-8tagfx/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Камелия Пандаклиева
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Камелия Пандаклиева
COINS = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
coin_collection = {}
sum = int(sum * 100)
for coin in COINS:
coin_collection[coin] = sum // coin
sum = sum - coin_collection[coin] * coin
return coin_collection
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-6dt61a/test.py", line 2, in <module>
    from homework import calculate_coins
Димитър Петров
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Димитър Петров
coins = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
def check_amount(amount, value):
count = 0
while amount >= value:
count += 1
amount -= value
return count
def update(sum, value):
add_amount = check_amount(sum, value)
coins[value] += add_amount
sum -= add_amount * value
return sum
def calculate_coins(sum):
sum *= 100
sum = update(sum, 100)
sum = update(sum, 50)
sum = update(sum, 20)
sum = update(sum, 10)
sum = update(sum, 5)
sum = update(sum, 2)
sum = update(sum, 1)
return coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-kvhxm1/test.py", line 2, in <module>
    from homework import calculate_coins
Радослав Рачев
  • Коректно
  • 4 успешни тест(а)
  • 0 неуспешни тест(а)
Радослав Рачев
from decimal import Decimal
COINS = [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(sum):
sum = Decimal(str(sum)) * 100
coins = dict()
for coin in COINS:
coins[coin] = int(sum // coin)
sum -= coins[coin] * coin
return coins
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
Радослав Върбанов
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Радослав Върбанов
COINS, NOMINALS = [0, 0, 0, 0, 0, 0, 0], [100, 50, 20, 10, 5, 2, 1]
def calculate_coins(money):
money *= 100
for index, nominal in enumerate(NOMINALS):
COINS[index] = int(money / nominal)
money %= nominal
return dict(zip(NOMINALS, COINS))
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-11mgawc/test.py", line 2, in <module>
    from homework import calculate_coins
Габриел Гатев
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Габриел Гатев
def calculate_coins(sum):
s=sum*100
coins = [100, 50, 20, 10, 5, 2, 1]
change = {100:0, 50:0, 20:0, 10:0, 5:0, 2:0, 1:0}
for i in range(0, 7):
while s>=coins[i]:
s-=coins[i]
change[coins[i]]=change[coins[i]]+1
return change
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-10wwmfe/test.py", line 2, in <module>
    from homework import calculate_coins
Мария Терзиева
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Мария Терзиева
def calculate_coins(sum):
coins = {}
sum_in_coins = int(sum*100)
for coin in (100, 50, 20, 10, 5, 2, 1):
coins[coin] = sum_in_coins//coin
sum_in_coins %= coin
return coins
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1wakg6v/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Мария Станчева
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Мария Станчева
distribution_coins = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
coins = {1: 100, 2: 50, 3: 20, 4: 10, 5: 5, 6: 2, 7: 1}
def calculate_coins(sum):
sum = sum * 100
i = 1
while i < 8:
while sum >= 0:
sum -= coins[i]
if(sum >= 0):
distribution_coins[coins[i]] += 1
sum = sum + coins[i]
i += 1
return distribution_coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-7i5srp/test.py", line 2, in <module>
    from homework import calculate_coins
Христина Христова
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Христина Христова
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
sum = round(sum*100)
min_num_coins = {}
for coin in COINS:
min_num_coins[coin] = int(sum // coin)
sum -= min_num_coins[coin]*coin
return min_num_coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-k5hu4/test.py", line 2, in <module>
    from homework import calculate_coins
Марин Койнов
  • Некоректно
  • 2 успешни тест(а)
  • 2 неуспешни тест(а)
Марин Койнов
def calculate_coins(sum):
dictsum = {1: 0, 2: 0, 5: 0, 10: 0, 20: 0, 50: 0, 100: 0}
sum = sum*100
lim = (100, 50, 20, 10, 5, 2, 1)
ref = 0
while sum < lim[ref]: ref = ref+1
while sum >= lim[ref]:
dictsum[lim[ref]] = dictsum[lim[ref]]+1
sum = sum-lim[ref]
while sum < lim[ref]:
ref = ref+1
if ref > 6: return dictsum
F..E
======================================================================
ERROR: test_zero (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-rj2g7r/test.py", line 10, in test_zero
    self.assertEqual(calculate_coins(0), self.zero_dict)
  File "/tmp/d20130323-7534-rj2g7r/solution.py", line 6, in calculate_coins
    while sum < lim[ref]: ref = ref+1
IndexError: tuple index out of range

======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130323-7534-rj2g7r/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1, errors=1)
Мартин Маринов
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Мартин Маринов
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(coins):
result = {}
coins *= 100
for coin in COINS:
result[coin] = coins//coin
coins %= coin
return result
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-9jvk97/test.py", line 2, in <module>
    from homework import calculate_coins
Николина Гюрова
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Николина Гюрова
def calculate_coins(sum):
sum_in_coins=int(sum*100)
dict_coins={1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
if(sum_in_coins<=0): return dict_coins
else:
coins=(1,2,5,10,20,50,100)
dp=list()
prev=list()
for s in range(0,sum_in_coins+1):
dp.append(sum_in_coins)
prev.append(sum_in_coins)
prev[0]=0
dp[0]=0
dp[1]=1
prev[1]=0
for coin in coins:
for s in range(1,sum_in_coins+1):
if s-coin>=0 and dp[s]>dp[s-coin]+1:
dp[s]=dp[s-coin]+1
prev[s]=s-coin
current=sum_in_coins
while(current):
dict_coins[current-prev[current]]+=1
current=prev[current]
return dict_coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-12s12ta/test.py", line 2, in <module>
    from homework import calculate_coins
Александър Тахчиев
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Александър Тахчиев
def calculate_coins(sum):
number_coins = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
VALUES_FRACTUS = {1: [1], 2: [2], 3: [1, 2], 4: [2, 2], 5: [5], 6: [1, 5],
7: [2, 5], 8: [1, 2, 5], 9: [2, 2, 5]}
number_coins[100] = (int(sum))
sum *= 100
second_digit = int(sum % 100 / 10)
third_digit = sum % 10
if second_digit:
for i in VALUES_FRACTUS[second_digit]:
number_coins[10 * i] += 1
if third_digit:
for i in VALUES_FRACTUS[third_digit]:
number_coins[i] += 1
return number_coins
E...
======================================================================
ERROR: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130325-7534-1yx2qe5/test.py", line 25, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.14), {1: 0, 2: 2, 5: 0, 10: 1, 20: 0, 50: 0, 100: 0})
  File "/tmp/d20130325-7534-1yx2qe5/solution.py", line 13, in calculate_coins
    for i in VALUES_FRACTUS[third_digit]:
KeyError: 4.000000000000002

----------------------------------------------------------------------
Ran 4 tests in 0.002s

FAILED (errors=1)
Николай Русев
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Николай Русев
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(money):
result = {}
money = int(money * 100)
for coin in COINS:
result[coin] = money // coin
money %= coin
return result
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-105tv0/test.py", line 2, in <module>
    from homework import calculate_coins
Борис Пелтеков
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Борис Пелтеков
# При произволни големини на монетите задачата се решава с динамично програмиране.
# Има обаче случай когато това просто грийди дава оптимален отговор.
# Сортираме низходящо номиналите. Ако всеки номинал е поне два пъти по-голям от непосредствено следващия го,
# то грийдито е оптимално. Лесно се доказва :)
from math import floor
def calculate_coins(sum):
COINS = [100, 50, 20, 10, 5, 2, 1]
res = {}
sum = floor(sum * 100)
for c in COINS:
res[c] = floor(sum / c)
sum %= c
return res
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-trytpo/test.py", line 2, in <module>
    from homework import calculate_coins
Георги Харизанов
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Георги Харизанов
answer = {1: 0, 2: 0, 100: 0, 5: 0, 10: 0, 50: 0, 20: 0}
coins = list(reversed(sorted((answer.keys()))))
def calculate_coins(sum):
sum = int(sum * 100)
for coin in coins:
answer[coin] = sum // coin
sum %= coin
return answer
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-757sbj/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 2: 0, 100: 0, 5: 1, 20: 0, 10: 0, 50: 1} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Кристиан Цветков
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Кристиан Цветков
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
sum = int(sum*100)
minimal_coin_division = {}
for coin in COINS:
minimal_coin_division[coin] = int(sum / coin)
sum = sum % coin
return minimal_coin_division
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-6562jw/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Гергана Маврова
  • Некоректно
  • 3 успешни тест(а)
  • 1 неуспешни тест(а)
Гергана Маврова
COINS = (100, 50, 20, 10, 5, 2, 1)
def calculate_coins(sum):
change = {}
sum = int(sum*100)
for coin in COINS:
count = sum//coin
sum -= coin*count
change.update({coin: count})
return change
F...
======================================================================
FAIL: test_floats_with_error_in_multiplication (test.CoinCalculatorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/d20130403-12177-1g32bag/test.py", line 26, in test_floats_with_error_in_multiplication
    self.assertEqual(calculate_coins(0.57), {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0})
AssertionError: {1: 1, 50: 1, 20: 0, 5: 1, 100: 0, 10: 0, 2: 0} != {1: 0, 2: 1, 20: 0, 5: 1, 100: 0, 10: 0, 50: 1}
- {1: 1, 2: 0, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?        ------

+ {1: 0, 2: 1, 5: 1, 10: 0, 20: 0, 50: 1, 100: 0}
?     ++++++


----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)
Фатих Хюсеинов
  • Некоректно
  • 0 успешни тест(а)
  • 0 неуспешни тест(а)
Фатих Хюсеинов
def calculate_coins(sum):
coins = {100: 0, 50: 0, 20: 0, 10: 0, 5: 0, 2: 0, 1: 0}
sum *= 100
e = sum%10
d = sum%100 - e
lv = sum%1000 - e - d
coins[100] = int(lv/100)
not_all = True
while not_all:
if d>=50:
coins[50] += 1
d = d-50
else:
if d>=20:
coins[20] +=1
d = d-20
else:
if d>=10:
coins[10] +=1
d = d-10
else: not_all=False
not_all=True
while not_all:
if e>=5:
coins[5] += 1
e = e-5
else :
if e>=2:
coins[2] +=1
e=e-2
else:
if e>=1:
coins[1] +=1
e=e-1
else: not_all=False
return coins
File "lib/language/python/runner.py", line 49, in main
    test = imp.load_source('test', test_module)
  File "/opt/python3.3/lib/python3.3/imp.py", line 109, in load_source
    return _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/tmp/d20130323-7534-10okz41/test.py", line 2, in <module>
    from homework import calculate_coins