views:

33

answers:

1

i need help enumerating all possible combinations of length n given a list of strings.

example, if my list was ["r","b","g"] and int 2 answer:

r r, r b, r g, b r, b b, b g, g r, g b, g g,

A: 

Smells like a homework problem, but here's a hint:

  • If I take all possible lists of length 58, and I remove the first element, I'll be left with all possible lists of length 57. But I'll have some duplicates.

  • How many duplicates will I have of each list?

  • Given any single list of length 57, will the original lists of length 58 be the same or different? If different, exactly how will they be different?

  • How many distinct lists of length 0 can you form from the elements r, g, b?

If you can answer these questions, I expect you can solve your problem.

Norman Ramsey