Write a method diceSum
that accepts an integer parameter representing a number of
6-sided dice to roll, and also a desired sum. The method returns only combinations that adds
up to exactly that sum.
The method should return a vector of all combinations in string type where each dice result is
concatenated together. For instance, the results of 2 and 6 as two dice rolls should be displayed as
a string of {26}
.
diceSum(2,7) ==> {"{16}","{25}","{34}","{43}","{52}","{61}"}
if there are no more choices to make: stop.
else, for each available choice C:
Choose C.
Explore the remaining choices.
Un-choose C. (backtrack!)
public static Vector<String> diceSum(int dice, int desiredSum) { }
C
Java
Python