I'm programming something for a text based game that I play and I've got a problem that I've been working on for a while and just about to just brute force it, but before I do I'm hoping someone has a solution. In my game you can get afflictions and to cure theses afflictions there are a number of cure methods that you can use periodically to heal them. The problem is that what order you use them matters. example:

lets say that you have the afflictions: {a1,a2,a3} and you have three curing methods that can cure one affliction of a given set

C1: {a1,a2,a3}

C2: {a1,a2,a3}

C3: {a1,a2}

if I use C1 and C2 before C3 then there's a 1/3 (proof below) chance that a1 and a2 get cured and using C3 and would be a waste of the curing method.

let A be the event that C1 cures a1 or a2, P(A) = 2/3

let B be the event that C2 cures a1 or a2, P(B) = 2/3

P(B|A) = 1/2. if a1 then left with a2 and a3, if a2 then left with a1 and a3 both of which are 50/50.

P(A and B) = P(B|A) * P(A) = 1/2 * 2/3 = 1/3.

This is ok for me and u to do, but getting the computer to do it is a tad different. What I'd like to do is find the sample space and the event space and get the probability that way. I know how to do it with dice, coins, cards, and bags of marbles because there's lots of examples of those kind of things, but being restricted to certain elements is something I haven't found, in my books or the net. Example

afflictions: {a1,a2,a3,a4}

C1: {a1,a2,a3,a4}

C2: {a1,a2,a3}

C3: {a1,a2}

gives 10 different combinations going c1,c2,c3 while going c3,c2,c1 gives 8 different combinations. Was wondering if there were a general way to figure out the number of combinations using the number of elements in each set?

C1,C2,C3:

1:a1,a2

2:a1,a3,a2

3:a2,a1

4:a2,a3,a1

5:a3,a1,a2

6:a3,a2,a1

7:a4,a1,a2

8:a4,a2,a1

9:a4,a3,a1

10:a4,a3,a2

C3,C2,C1:

1:a1,a2,a3

2:a1,a2,a4

3:a1,a3,a2

4:a1,a3,a4

5:a2,a1,a3

6:a2,a1,a4

7:a2,a3,a1

8:a2,a3,a4