Count the number of score combinations
ScoreCombination.javapublic static long countCombinations(int k, List<Integer> scoreWays) {
long[] combinations = new long[k + 1];
combinations[0] = 1; // One way to reach 0.
for (int score : scoreWays) {
for (int j = score; j <= k; ++j) {
combinations[j] += combinations[j - score];
}
}
return combinations[k];
}
ScorePermutation.java
public static long countPermutations(int k, List<Integer> scoreWays) {
long[] permutations = new long[k + 1];
permutations[0] = 1; // One way to reach 0.
for (int i = 0; i <= k; ++i) {
for (int score : scoreWays) {
if (i >= score) {
permutations[i] += permutations[i - score];
}
}
}
return permutations[k];
}