(coming from PR dnd-character: Add test case for ability with lowest number occurring twice by kahgoh · Pull Request #2792 · exercism/java · GitHub)
During a mentoring session for the DnD Character exercise on the Java track, I noticed a passed all the tests for the ability
method but wouldn’t meet the example below from the instructions. I wonder if it would be worth adding a test for it?
3, 5, 3, 4: You discard the 3 and sum 5 + 3 + 4 = 12, which you assign to wisdom.
The solution’s implementation looked like this:
int ability(List<Integer> scores) {
if (allScoresAreTheSame(scores)) {
return 3 * scores.get(0);
}
int smallestScore = Collections.min(scores);
return scores
.stream()
.filter((score) -> smallestScore != score)
.reduce(0, (total, score) -> total + score);
}
I notice the existing ability
tests aren’t in the problem specifications. Perhaps they could be Java specific?