knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The permutations package provides R-centric functionality for working with permutations of a finite set. It includes group-theoretic composition of permutations and can transform from word form to cycle form and back.
You can install the released version of permutations from CRAN with:
# install.packages("permutations") # uncomment this to use the package library("permutations")
The package is maintained on github.
permutations
package in useRandom permutations on a finite set are given by the rperm()
command:
set.seed(0)
(x <- rperm(10,9))
Above, object x
is internally stored as a matrix (word form) but the
result is printed in cycle form by default, as this is easier to
understand. We can print in word form if we wish:
options(print_word_as_cycle=FALSE) # override default as.word(x) options(print_word_as_cycle=TRUE) # restore default: we usually want to print a cycle irregardless
(A dot indicates a fixed point). The package uses arithmetic
operations *
to combine permutations and ^
for
conjugation:
(a <- as.word(c(4,2,3,1,5,7,6))) (b <- as.cycle(1:4)) a*b b*a
The megaminx is a dodecahedral puzzle with similar construction to the Rubik cube puzzle that has 50 movable pieces and 132 coloured stickers ("facets"). The permutations package includes functionality to simulate the megaminx and exhibits an 82-turn superflip. The vignette gives an extended discussion.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.