Exemplo n.º 1
0
    public void Possible_change_without_unit_coins_available()
    {
        var coins    = new[] { 2, 5, 10, 20, 50 };
        var target   = 21;
        var expected = new[] { 2, 2, 2, 5, 10 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }
Exemplo n.º 2
0
    public void Large_target_values()
    {
        var coins    = new[] { 1, 2, 5, 10, 20, 50, 100 };
        var target   = 999;
        var expected = new[] { 2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }
Exemplo n.º 3
0
    public void Change_with_lower_elbonia_coins()
    {
        var coins    = new[] { 1, 5, 10, 21, 25 };
        var target   = 63;
        var expected = new[] { 21, 21, 21 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }
Exemplo n.º 4
0
    public void Change_with_lilliputian_coins()
    {
        var coins    = new[] { 1, 4, 15, 20, 50 };
        var target   = 23;
        var expected = new[] { 4, 4, 15 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }
Exemplo n.º 5
0
    public void Multiple_coin_change()
    {
        var coins    = new[] { 1, 5, 10, 25, 100 };
        var target   = 15;
        var expected = new[] { 5, 10 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }
Exemplo n.º 6
0
    public void Another_possible_change_without_unit_coins_available()
    {
        var coins    = new[] { 4, 5 };
        var target   = 27;
        var expected = new[] { 4, 4, 4, 5, 5, 5 };

        Assert.Equal(expected, Change.FindFewestCoins(coins, target));
    }