faro | R Documentation |
A faro shuffle, faro()
,is a permutation of a deck of
2n
cards. The cards are split into two packs, 1:n
and
(n+1):2n
, and interleaved: cards are taken alternately from top
of each pack and placed face down on the table. A faro
out-shuffle takes the first card from 1:n
and a faro
in-shuffle takes the first card from (n+1):(2*n)
.
A generalized faro shuffle, faro_gen()
, splits the pack
into m
equal parts and applies the same permutation to each pack,
and the same permutation to each set of packs, before interleaving.
The interleaving itself is simply a matrix transpose; it is possible to
omit this step by passing interleave=FALSE
.
faro(n, out = TRUE)
faro_gen(n,m,p1=id,p2=id,interleave=TRUE)
n |
Number of cards in each pack |
m |
Number of packs |
p1 , p2 |
Permutations for cards and packs respectively, coerced to word form |
interleave |
Boolean, with default |
out |
Boolean, with default |
Returns a permutation in word form
Robin K. S. Hankin
faro(4)
faro(4,FALSE)
faro_gen(9,3)
faro_gen(7,4,cyc_len(7),cyc_len(4))
faro_gen(7,4,cyc_len(7),cyc_len(4),interleave=FALSE)
sapply(seq_len(10),function(n){permorder(faro(n,FALSE))}) # OEIS A002326
plot(as.vector(as.word(faro(10))),type='b')
plot(as.vector(faro_gen(8,5,p1=cyc_len(8)^2,interleave=FALSE)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.