using System.Collections;
public static ArrayList combos(int nDice, int tot, int max)
var res = new ArrayList();
combos(res, "", nDice, tot, max);
private static void combos(ArrayList res, String sol, int nDice, int tot, int max)
for(int side = 1+(tot-1)/nDice; side <= Math.Min(tot, max); side++)
combos(res, sol+side, nDice-1, tot-side, side);
public static void Main (string[] args) {
for(int tot=1; tot<=nDice*nFaces+1; tot++)
Console.WriteLine ("\ntot: " + tot);
foreach (var combo in combos(nDice, tot, nFaces)) {
Console.WriteLine (combo);