[R] Help finding valid permutations

Michael D mike409 at gmail.com
Fri Jul 9 18:36:57 CEST 2010


So I have an array A of length n with multiple attributes and for a
selected attribute y I need to list all valid permutations where a
valid permutation is of the form:
A[1,y] != A[n,y]
A[i,y] != A[i+1,y]

I've tried using the 'combinat' package, but with the vector lengths
I'm using the permn function fails with the vector("list", gamma(n +
1)) assignment.


For example:
13 cards from a standard 52 card deck. attributes facevalue and suit.
A = (9C, 9H, 9D, 8C, 7C, 6C, 6S, 5C, 4C, 4H, 3C, 2C, 2D)

And I want to find all possible arrangements where the facevalue of
each consecutive card is different but the orders are unique because
of the suit.

Also, I need to consider the case where the suit of each consecutive
case is different but the orders are unique because of the facevalue.

For A above, note that there are 8 clubs out of 13 cards so 3 of the
clubs must be dropped from the draw an all valid of ten of the cards
must be found (5 same suit, 5 off suit)


I hope this is clear. Thanks.



More information about the R-help mailing list