I am trying to construct combinations of sequences. Given n integers (to choose from), say 1 <= n <= k and the requirements to construct sequences of length m. The number of sequences is simply C(n, r) and I even have a program to display them all.
However, now I am trying to construct sequences where no adjacent numbers are only 1 digit apart, let's call it S. I can easily list them all with my program. For example. S(9,4):
1 3 5 7
1 3 5 8
1 3 5 9
1 3 6 8
1 3 6 9
1 3 7 9
1 4 6 8
1 4 6 9
1 4 7 9
1 5 7 9
2 4 6 8
2 4 6 9
2 4 7 9
2 5 7 9
3 5 7 9
tot:15
I need to work out the "15" without listing them all.
So, to calculate S(n,m), I know that in terms of permutations, it simply is: n(n-2)(n-4)..(n-2m). However, that gives me permutations and not only combinations? A little help here please... How can I work this out?