# =============================================================================
# Calculate quantites of differents coin
# Luis Lopez Diaz - llopeza@uninorte.edu.co
# =============================================================================
# Input data
m = 1800;                       # Money in $
# =============================================================================
if m < 0
    error("Money needs to be positive.");
    return;
end
if ~(typeof(m) == Int)
    error("Money needs to be integer.");
    return;
end
# =============================================================================
# List of coins availables
coins = [1000 500 200 100 50];  # Available coins in sort
nCoins = length(coins);         # Number of coins
qCoins = zeros(1,nCoins);       # Vector for number of coins
for i in 1:nCoins
    global m;
    if m/coins[i] >= 1
        qCoins[i] = div(m,coins[i]);    # Calculate quantites of coins i
        m = m - qCoins[i]*coins[i];     # Updating value of money
    end
end
if m > 0
    error("Not posible to reach with coins this money.");
    return;
end
# =============================================================================
# Printing results
println("Total number of coins: ", sum(qCoins));
for i in 1:nCoins
    if qCoins[i] != 0
        println(coins[i], " coins: ",qCoins[i]);
    end
end
