My program is tasked to count all possible combinations of getting the value of T, with a list of coins with varying (and some identical) values with limited amount of coins.
Two coins with different names could have a same value, for example both "Gold" and "Topaz" coins both have a value of 3.
public static int change(int target, ArrayList<GemCoin> coinStocks) {
int[] combi = new int[target + 1];
combi[0] = 1;
for (GemCoin g: coinStocks) {
for (int i = 1; i < combi.length; i++) {
if (i >= g.getValue() && g.getStocks() > 0) { ///if
combi[i] += combi[i - d.getChips()];
}
}
}
for(int im : combi){
System.out.println(im);
}
return combi[target];
}
That's my general idea, but i do notice that the coin stocks "ran out" before reaching the last index in combi, even though there exists a combination involving that coin.