One way of solving
S = {3,2,1}
all allowed ordered pairs
- (1,1)
- (1,2)
- (1,3)
- (2,2)
- (2,3)
- (3,3)
we can append all 6 pairs after (1,1) = 6 (1111,1112,1113,1122,1123,1133)
we can append all pairs after (1,2) with (1,2) except 3rd = 3
we can append all pairs after (1,3) with (1,2) except 3rd = 2
we can append 4th 5th and 6th pairs with (2,2) = 3
we can append only one pair 6th with (2,3) = 1
we can append (3,3) with itself = 1
6+3+2+3+1+1 = 15