PERM: Enumerating Gene Orders | Ben Cunningham

# PERM: Enumerating Gene Orders

Problem by Rosalind · on August 1, 2012

A permutation of length $n$ is an ordering of the positive integers $\{1, 2, \ldots, n\}$. For example, $\pi = (5, 3, 2, 1, 4)$ is a permutation of length 55.

Given: A positive integer $n \leq 7$.

Return: The total number of permutations of length $n$, followed by a list of all such permutations (in any order).

## Sample Dataset

3


## Sample Output

6
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1


# R

library(gtools)

Error in library(gtools): there is no package called 'gtools'

library(magrittr)

f <- "perm.txt"


Error in permutations(n, n, v = 1:n): could not find function "permutations"

apply(p, 1, paste, collapse = " ") %>%

Error in apply(p, 1, paste, collapse = " "): object 'p' not found