Question: Why can't I add values to the list inside a created class? ex. I write carType\_list.add

```
class Vehicles
{
    List<string> carType_list = new List<string>();
    List<string> carModel_list = new List<string>();
    List<int> seatCapacity_list = new List<int>();
    List<string> mileageLimit_list = new List<string>();
    List<double> ratings_list = new List<double>();
    List<double> rentPrice_list = new List<double>();
}

```

Answer: 
Generating all of the possible combinations of faces of dice in this problem is way overkill. For 3 dice, this is tenable, but quickly becomes infeasible as the number of dice increases to even double digits. As the OP points out, there are a total of 216 possible rolls of 3 dice, only 6 of which total to 5.

Here is a version that only visits the necessary faces to list them all. The general intuition is to simply pick the first die, then consider the n-1 dice problem summing to `total-first_die`. We can enforce sorting if we only want to get the combinations, and not the permutations. You can see exactly how many nodes are visited by viewing the print statements.

```
""" generates integer partitions of total consisting of exactly n_dice summands
    summands are constrained from dmin to dmax.
    partition_so_far is used in the recursion, and should always be None when the user calls iterdice.
    ordered is whether to consider combinations (False) or permutations (True)
"""
def iterdice(n_dice=3, dmin=1, dmax=6, total=5, partition_so_far=None, ordered=False):
    print(n_dice, dmin, dmax, total, partition_so_far)
    # initialize your partition
    if partition_so_far is None:
        partition_so_far = []
    # recursion base case
    if n_dice == 1:
        yield partition_so_far + [total]
        return None
    # iterate over possibilities for the next die
    # if we want *combinations*, enforce sorting by updating dmin and die_max
    # note that the current die value can't be bigger than 
    #   total/n_dice (combinations)... otherwise, we'll run over with our dice.
    #   e.g. if total==5 and n_dice==3, this die can't be 2 
    #   (because the next two would have to be at least 2)
    # (alternatively, for permutations, current die value can't be bigger than 
    #   total - dmin*(n_dice-1)
    # note that the current die value can't be smaller than 
    #   total - dmax*(n_dice-1)... otherwise, we'll never get to total
    die_min = max(dmin, total-dmax*(n_dice-1))
    die_max = min(dmax, total-dmin*(n_dice-1) if ordered else int(total/n_dice) )
    for next_die in range(die_min, die_max+1):
        partition = partition_so_far + [next_die]
        yield from iterdice(n_dice-1, dmin if ordered else next_die, dmax, total-next_die, partition, ordered)

# test
if __name__ == "__main__":
    from pprint import pprint
    pprint(list(iterdice(3, 1, 6, 5, None, True))) 

```
This will do it:

```
from itertools import product

A  = [x for x in product(range(1,7), repeat=3) if sum(x) == 5]

```