Importamos la librería

library(gtools)

Creamos el conjunto de 10 nombres y lo mostramos.

nombres <- c("Anand", "Laura", "Alicia", "Romeo", "Alonso", "Alberto", "Adriana", "Mary", "Olga", "Paty")
nombres
##  [1] "Anand"   "Laura"   "Alicia"  "Romeo"   "Alonso"  "Alberto" "Adriana"
##  [8] "Mary"    "Olga"    "Paty"

Combinaciones.

Creamos las combinaciones de los 10 nombres en grupos de 2 y las mostramos.

comb2 <- combinations(10, 2, nombres)
head(comb2)
##      [,1]      [,2]     
## [1,] "Adriana" "Alberto"
## [2,] "Adriana" "Alicia" 
## [3,] "Adriana" "Alonso" 
## [4,] "Adriana" "Anand"  
## [5,] "Adriana" "Laura"  
## [6,] "Adriana" "Mary"
tail(comb2)
##       [,1]   [,2]   
## [40,] "Mary" "Olga" 
## [41,] "Mary" "Paty" 
## [42,] "Mary" "Romeo"
## [43,] "Olga" "Paty" 
## [44,] "Olga" "Romeo"
## [45,] "Paty" "Romeo"
cuant2 <- length(comb2[,1])
## Hay  45  combinaciones en grupos de 2.

Creamos las combinaciones de los 10 nombres en grupos de 4 y las mostramos.

comb4 <- combinations(10, 4, nombres)
head(comb4)
##      [,1]      [,2]      [,3]     [,4]    
## [1,] "Adriana" "Alberto" "Alicia" "Alonso"
## [2,] "Adriana" "Alberto" "Alicia" "Anand" 
## [3,] "Adriana" "Alberto" "Alicia" "Laura" 
## [4,] "Adriana" "Alberto" "Alicia" "Mary"  
## [5,] "Adriana" "Alberto" "Alicia" "Olga"  
## [6,] "Adriana" "Alberto" "Alicia" "Paty"
tail(comb4)
##        [,1]    [,2]   [,3]   [,4]   
## [205,] "Anand" "Olga" "Paty" "Romeo"
## [206,] "Laura" "Mary" "Olga" "Paty" 
## [207,] "Laura" "Mary" "Olga" "Romeo"
## [208,] "Laura" "Mary" "Paty" "Romeo"
## [209,] "Laura" "Olga" "Paty" "Romeo"
## [210,] "Mary"  "Olga" "Paty" "Romeo"
cuant4 <- length(comb4[,1])
## Hay  210  combinaciones en grupos de 4.

Creamos las combinaciones de los 10 nombres en grupos de 6 y las mostramos.

comb6 <- combinations(10, 6, nombres)
head(comb6)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Laura"
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Mary" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Olga" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Paty" 
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Romeo"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Mary"
tail(comb6)
##        [,1]     [,2]    [,3]    [,4]   [,5]   [,6]   
## [205,] "Alonso" "Anand" "Laura" "Mary" "Olga" "Romeo"
## [206,] "Alonso" "Anand" "Laura" "Mary" "Paty" "Romeo"
## [207,] "Alonso" "Anand" "Laura" "Olga" "Paty" "Romeo"
## [208,] "Alonso" "Anand" "Mary"  "Olga" "Paty" "Romeo"
## [209,] "Alonso" "Laura" "Mary"  "Olga" "Paty" "Romeo"
## [210,] "Anand"  "Laura" "Mary"  "Olga" "Paty" "Romeo"
cuant6 <- length(comb6[,1])
## Hay  210  combinaciones en grupos de 6.

Permutaciones.

Creamos las permutaciones de los 10 nombres en grupos de 2 y las mostramos.

per2 <- permutations(10, 2, nombres)
head(per2)
##      [,1]      [,2]     
## [1,] "Adriana" "Alberto"
## [2,] "Adriana" "Alicia" 
## [3,] "Adriana" "Alonso" 
## [4,] "Adriana" "Anand"  
## [5,] "Adriana" "Laura"  
## [6,] "Adriana" "Mary"
tail(per2)
##       [,1]    [,2]    
## [85,] "Romeo" "Alonso"
## [86,] "Romeo" "Anand" 
## [87,] "Romeo" "Laura" 
## [88,] "Romeo" "Mary"  
## [89,] "Romeo" "Olga"  
## [90,] "Romeo" "Paty"
cuanp2 <- length(per2[,1])
## Hay  90  permutaciones en grupos de 2.

Creamos las permutaciones de los 10 nombres en grupos de 4 y las mostramos.

per4 <- permutations(10, 4, nombres)
head(per4)
##      [,1]      [,2]      [,3]     [,4]    
## [1,] "Adriana" "Alberto" "Alicia" "Alonso"
## [2,] "Adriana" "Alberto" "Alicia" "Anand" 
## [3,] "Adriana" "Alberto" "Alicia" "Laura" 
## [4,] "Adriana" "Alberto" "Alicia" "Mary"  
## [5,] "Adriana" "Alberto" "Alicia" "Olga"  
## [6,] "Adriana" "Alberto" "Alicia" "Paty"
tail(per4)
##         [,1]    [,2]   [,3]   [,4]     
## [5035,] "Romeo" "Paty" "Olga" "Alberto"
## [5036,] "Romeo" "Paty" "Olga" "Alicia" 
## [5037,] "Romeo" "Paty" "Olga" "Alonso" 
## [5038,] "Romeo" "Paty" "Olga" "Anand"  
## [5039,] "Romeo" "Paty" "Olga" "Laura"  
## [5040,] "Romeo" "Paty" "Olga" "Mary"
cuanp4 <- length(per4[,1])
## Hay  5040  permutaciones en grupos de 4.

Creamos las permutaciones de los 10 nombres en grupos de 6 y las mostramos.

per6 <- permutations(10, 6, nombres)
head(per6)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Laura"
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Mary" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Olga" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Paty" 
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Romeo"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Anand"
tail(per6)
##           [,1]    [,2]   [,3]   [,4]   [,5]    [,6]     
## [151195,] "Romeo" "Paty" "Olga" "Mary" "Anand" "Laura"  
## [151196,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Adriana"
## [151197,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alberto"
## [151198,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alicia" 
## [151199,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alonso" 
## [151200,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Anand"
cuanp6 <- length(per6[,1])
## Hay  151200  permutaciones en grupos de 6.

PREGUNTAS

1.- ¿En cuántas combinaciones de grupos de 6 está Adriana en la primera columna?

tabc6 = data.frame(comb6)
r1 = filter(tabc6, X1 == 'Adriana')  %>% select(X1, X2, X3, X4, X5, X6)
head(r1)
##        X1      X2     X3     X4    X5    X6
## 1 Adriana Alberto Alicia Alonso Anand Laura
## 2 Adriana Alberto Alicia Alonso Anand  Mary
## 3 Adriana Alberto Alicia Alonso Anand  Olga
## 4 Adriana Alberto Alicia Alonso Anand  Paty
## 5 Adriana Alberto Alicia Alonso Anand Romeo
## 6 Adriana Alberto Alicia Alonso Laura  Mary
resp1 = nrow(r1)
## Hay  126  combinaciones de grupos de 6 en las que Adriana está en la primer columna.

2.- ¿En cuántas combinaciones de grupos de 6 está Adriana en la primera, segunda o tercer columna?

tabc6 = data.frame(comb6)
r2_1 = filter(tabc6, X1 == 'Adriana')  %>% select(X1, X2, X3, X4, X5, X6)
head(r2_1)
##        X1      X2     X3     X4    X5    X6
## 1 Adriana Alberto Alicia Alonso Anand Laura
## 2 Adriana Alberto Alicia Alonso Anand  Mary
## 3 Adriana Alberto Alicia Alonso Anand  Olga
## 4 Adriana Alberto Alicia Alonso Anand  Paty
## 5 Adriana Alberto Alicia Alonso Anand Romeo
## 6 Adriana Alberto Alicia Alonso Laura  Mary
r2_2 = filter(tabc6, X2 == 'Adriana')  %>% select(X1, X2, X3, X4, X5, X6)
head(r2_2)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
r2_3 = filter(tabc6, X3 == 'Adriana')  %>% select(X1, X2, X3, X4, X5, X6)
head(r2_3)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
resp2 = nrow(r2_1) + nrow(r2_2) + nrow(r2_3)
## Hay  126  combinaciones de grupos de 6 en las que Adriana está en la primer, segunda o tercer columna.

3.- ¿En cuántas combinaciones de grupos de 6 está Paty en la cuarta, quinta o sexta columna?

tabc6 = data.frame(comb6)
r3_1 = filter(tabc6, X4 == 'Paty')  %>% select(X1, X2, X3, X4, X5, X6)
head(r3_1)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
r3_2 = filter(tabc6, X5 == 'Paty')  %>% select(X1, X2, X3, X4, X5, X6)
head(r3_2)
##        X1      X2     X3     X4   X5    X6
## 1 Adriana Alberto Alicia Alonso Paty Romeo
## 2 Adriana Alberto Alicia  Anand Paty Romeo
## 3 Adriana Alberto Alicia  Laura Paty Romeo
## 4 Adriana Alberto Alicia   Mary Paty Romeo
## 5 Adriana Alberto Alicia   Olga Paty Romeo
## 6 Adriana Alberto Alonso  Anand Paty Romeo
r3_3 = filter(tabc6, X6 == 'Paty')  %>% select(X1, X2, X3, X4, X5, X6)
head(r3_3)
##        X1      X2     X3     X4    X5   X6
## 1 Adriana Alberto Alicia Alonso Anand Paty
## 2 Adriana Alberto Alicia Alonso Laura Paty
## 3 Adriana Alberto Alicia Alonso  Mary Paty
## 4 Adriana Alberto Alicia Alonso  Olga Paty
## 5 Adriana Alberto Alicia  Anand Laura Paty
## 6 Adriana Alberto Alicia  Anand  Mary Paty
resp3 = nrow(r3_1) + nrow(r3_2) + nrow(r3_3)
## Hay  126  combinaciones de grupos de 6 en las que Paty está en la cuarta, quinta o sexta columna.

4.- ¿En cuántas combinaciones de grupos de 6 está Olga en la cuarta, quinta o sexta columna?

tabc6 = data.frame(comb6)
r4_1 = filter(tabc6, X4 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r4_1)
##        X1      X2     X3   X4   X5    X6
## 1 Adriana Alberto Alicia Olga Paty Romeo
## 2 Adriana Alberto Alonso Olga Paty Romeo
## 3 Adriana Alberto  Anand Olga Paty Romeo
## 4 Adriana Alberto  Laura Olga Paty Romeo
## 5 Adriana Alberto   Mary Olga Paty Romeo
## 6 Adriana  Alicia Alonso Olga Paty Romeo
r4_2 = filter(tabc6, X5 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r4_2)
##        X1      X2     X3     X4   X5    X6
## 1 Adriana Alberto Alicia Alonso Olga  Paty
## 2 Adriana Alberto Alicia Alonso Olga Romeo
## 3 Adriana Alberto Alicia  Anand Olga  Paty
## 4 Adriana Alberto Alicia  Anand Olga Romeo
## 5 Adriana Alberto Alicia  Laura Olga  Paty
## 6 Adriana Alberto Alicia  Laura Olga Romeo
r4_3 = filter(tabc6, X6 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r4_3)
##        X1      X2     X3     X4    X5   X6
## 1 Adriana Alberto Alicia Alonso Anand Olga
## 2 Adriana Alberto Alicia Alonso Laura Olga
## 3 Adriana Alberto Alicia Alonso  Mary Olga
## 4 Adriana Alberto Alicia  Anand Laura Olga
## 5 Adriana Alberto Alicia  Anand  Mary Olga
## 6 Adriana Alberto Alicia  Laura  Mary Olga
resp4 = nrow(r4_1) + nrow(r4_2) + nrow(r4_3)
## Hay  126  combinaciones de grupos de 6 en las que Olga está en la cuarta, quinta o sexta columna.

5.- ¿En cuántas combinaciones de grupos de 6 está Olga en cualquier columna de la 1 a la 6?

tabc6 = data.frame(comb6)
r5_1 = filter(tabc6, X1 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_1)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
r5_2 = filter(tabc6, X2 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_2)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
r5_3 = filter(tabc6, X3 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_3)
## [1] X1 X2 X3 X4 X5 X6
## <0 rows> (or 0-length row.names)
r5_4 = filter(tabc6, X4 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_4)
##        X1      X2     X3   X4   X5    X6
## 1 Adriana Alberto Alicia Olga Paty Romeo
## 2 Adriana Alberto Alonso Olga Paty Romeo
## 3 Adriana Alberto  Anand Olga Paty Romeo
## 4 Adriana Alberto  Laura Olga Paty Romeo
## 5 Adriana Alberto   Mary Olga Paty Romeo
## 6 Adriana  Alicia Alonso Olga Paty Romeo
r5_5 = filter(tabc6, X5 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_5)
##        X1      X2     X3     X4   X5    X6
## 1 Adriana Alberto Alicia Alonso Olga  Paty
## 2 Adriana Alberto Alicia Alonso Olga Romeo
## 3 Adriana Alberto Alicia  Anand Olga  Paty
## 4 Adriana Alberto Alicia  Anand Olga Romeo
## 5 Adriana Alberto Alicia  Laura Olga  Paty
## 6 Adriana Alberto Alicia  Laura Olga Romeo
r5_6 = filter(tabc6, X6 == 'Olga')  %>% select(X1, X2, X3, X4, X5, X6)
head(r5_6)
##        X1      X2     X3     X4    X5   X6
## 1 Adriana Alberto Alicia Alonso Anand Olga
## 2 Adriana Alberto Alicia Alonso Laura Olga
## 3 Adriana Alberto Alicia Alonso  Mary Olga
## 4 Adriana Alberto Alicia  Anand Laura Olga
## 5 Adriana Alberto Alicia  Anand  Mary Olga
## 6 Adriana Alberto Alicia  Laura  Mary Olga
resp5 = nrow(r5_1) + nrow(r5_2) + nrow(r5_3) + nrow(r5_4) + nrow(r5_5) + nrow(r5_6)
## Hay  126  combinaciones de grupos de 6 en las que Olga está en cualquier columna de la 1 a la 6.

6.- ¿En cuántas combinaciones de grupos de 6 están Adriana, Mary, Olga y Paty en cualquier columna de la 1 a la 6?

tabc6 = data.frame(comb6)

r6 = comb6[which((comb6[,1] == 'Adriana' | comb6[,2] == 'Adriana' | comb6[,3] == 'Adriana' | comb6[,4] == 'Adriana' | comb6[,5] == 'Adriana' | comb6[,6] == 'Adriana') & (comb6[,1] == 'Mary' | comb6[,2] == 'Mary' | comb6[,3] == 'Mary' | comb6[,4] == 'Mary' | comb6[,5] == 'Mary' | comb6[,6] == 'Mary') & (comb6[,1] == 'Olga' | comb6[,2] == 'Olga' | comb6[,3] == 'Olga' | comb6[,4] == 'Olga' | comb6[,5] == 'Olga' | comb6[,6] == 'Olga') & (comb6[,1] == 'Paty' | comb6[,2] == 'Paty' | comb6[,3] == 'Paty' | comb6[,4] == 'Paty' | comb6[,5] == 'Paty' | comb6[,6] == 'Paty')),]
r6
##       [,1]      [,2]      [,3]     [,4]   [,5]   [,6]   
##  [1,] "Adriana" "Alberto" "Alicia" "Mary" "Olga" "Paty" 
##  [2,] "Adriana" "Alberto" "Alonso" "Mary" "Olga" "Paty" 
##  [3,] "Adriana" "Alberto" "Anand"  "Mary" "Olga" "Paty" 
##  [4,] "Adriana" "Alberto" "Laura"  "Mary" "Olga" "Paty" 
##  [5,] "Adriana" "Alberto" "Mary"   "Olga" "Paty" "Romeo"
##  [6,] "Adriana" "Alicia"  "Alonso" "Mary" "Olga" "Paty" 
##  [7,] "Adriana" "Alicia"  "Anand"  "Mary" "Olga" "Paty" 
##  [8,] "Adriana" "Alicia"  "Laura"  "Mary" "Olga" "Paty" 
##  [9,] "Adriana" "Alicia"  "Mary"   "Olga" "Paty" "Romeo"
## [10,] "Adriana" "Alonso"  "Anand"  "Mary" "Olga" "Paty" 
## [11,] "Adriana" "Alonso"  "Laura"  "Mary" "Olga" "Paty" 
## [12,] "Adriana" "Alonso"  "Mary"   "Olga" "Paty" "Romeo"
## [13,] "Adriana" "Anand"   "Laura"  "Mary" "Olga" "Paty" 
## [14,] "Adriana" "Anand"   "Mary"   "Olga" "Paty" "Romeo"
## [15,] "Adriana" "Laura"   "Mary"   "Olga" "Paty" "Romeo"
resp6 = nrow(r6)
## Hay  15  combinaciones de grupos de 6 en las que Adriana, Mary, Olga y Paty están en cualquier columna de la 1 a la 6.

7.- ¿En cuántas permutaciones de grupos de 6 está Adriana en la primer, segunda o tercera columna?

r7 = per6[which(per6[,1] == 'Adriana' | per6[,2] == 'Adriana' | per6[,3] == 'Adriana'),]
head(r7)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Laura"
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Mary" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Olga" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Paty" 
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Romeo"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Anand"
tail(r7)
##          [,1]    [,2]   [,3]      [,4]   [,5]    [,6]     
## [45355,] "Romeo" "Paty" "Adriana" "Olga" "Laura" "Mary"   
## [45356,] "Romeo" "Paty" "Adriana" "Olga" "Mary"  "Alberto"
## [45357,] "Romeo" "Paty" "Adriana" "Olga" "Mary"  "Alicia" 
## [45358,] "Romeo" "Paty" "Adriana" "Olga" "Mary"  "Alonso" 
## [45359,] "Romeo" "Paty" "Adriana" "Olga" "Mary"  "Anand"  
## [45360,] "Romeo" "Paty" "Adriana" "Olga" "Mary"  "Laura"
resp7 = nrow(r7)
## Hay  45360  permutaciones de grupos de 6 en las que Adriana está en la primer, segunda o tercer columna.

8.- ¿En cuántas permutaciones de grupos de 6 está Paty en la cuarta, quinta o sexta columna?

r8 = per6[which(per6[,4] == 'Paty' | per6[,5] == 'Paty' | per6[,6] == 'Paty'),]
head(r8)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Paty" 
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Paty" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Mary"  "Paty" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Paty" 
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Paty"  "Anand"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Paty"  "Laura"
tail(r8)
##          [,1]    [,2]   [,3]   [,4]   [,5]    [,6]     
## [45355,] "Romeo" "Olga" "Mary" "Paty" "Anand" "Laura"  
## [45356,] "Romeo" "Olga" "Mary" "Paty" "Laura" "Adriana"
## [45357,] "Romeo" "Olga" "Mary" "Paty" "Laura" "Alberto"
## [45358,] "Romeo" "Olga" "Mary" "Paty" "Laura" "Alicia" 
## [45359,] "Romeo" "Olga" "Mary" "Paty" "Laura" "Alonso" 
## [45360,] "Romeo" "Olga" "Mary" "Paty" "Laura" "Anand"
resp8 = nrow(r8)
## Hay  45360  permutaciones de grupos de 6 en las que Paty está en la cuarta, quinta o sexta columna.

9.- ¿En cuántas permutaciones de grupos de 6 está Olga en la cuarta, quinta o sexta columna?

r9 = per6[which(per6[,4] == 'Olga' | per6[,5] == 'Olga' | per6[,6] == 'Olga'),]
head(r9)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Olga" 
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Olga" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Mary"  "Olga" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Anand"
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Laura"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Mary"
tail(r9)
##          [,1]    [,2]   [,3]   [,4]   [,5]    [,6]     
## [45355,] "Romeo" "Paty" "Mary" "Olga" "Anand" "Laura"  
## [45356,] "Romeo" "Paty" "Mary" "Olga" "Laura" "Adriana"
## [45357,] "Romeo" "Paty" "Mary" "Olga" "Laura" "Alberto"
## [45358,] "Romeo" "Paty" "Mary" "Olga" "Laura" "Alicia" 
## [45359,] "Romeo" "Paty" "Mary" "Olga" "Laura" "Alonso" 
## [45360,] "Romeo" "Paty" "Mary" "Olga" "Laura" "Anand"
resp9 = nrow(r9)
## Hay  45360  permutaciones de grupos de 6 en las que Olga está en la cuarta, quinta o sexta columna.

10.- ¿En cuántas permutaciones de grupos de 6 está Olga en la cualquier columna de la 1 a la 6?

r10 = per6[which(per6[,1] == 'Olga' | per6[,2] == 'Olga' | per6[,3] == 'Olga' | per6[,4] == 'Olga' | per6[,5] == 'Olga' | per6[,6] == 'Olga'),]
head(r10)
##      [,1]      [,2]      [,3]     [,4]     [,5]    [,6]   
## [1,] "Adriana" "Alberto" "Alicia" "Alonso" "Anand" "Olga" 
## [2,] "Adriana" "Alberto" "Alicia" "Alonso" "Laura" "Olga" 
## [3,] "Adriana" "Alberto" "Alicia" "Alonso" "Mary"  "Olga" 
## [4,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Anand"
## [5,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Laura"
## [6,] "Adriana" "Alberto" "Alicia" "Alonso" "Olga"  "Mary"
tail(r10)
##          [,1]    [,2]   [,3]   [,4]   [,5]    [,6]     
## [90715,] "Romeo" "Paty" "Olga" "Mary" "Anand" "Laura"  
## [90716,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Adriana"
## [90717,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alberto"
## [90718,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alicia" 
## [90719,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Alonso" 
## [90720,] "Romeo" "Paty" "Olga" "Mary" "Laura" "Anand"
resp10 = nrow(r10)
## Hay  90720  permutaciones de grupos de 6 en las que Olga está en cualquier columna de la 1 a la 6.

11.- ¿En cuántas permutaciones de grupos de 6 están Adriana, Mary, Olga y Paty en cualquier columna de la 1 a la 6?

r11 = per6[which((per6[,1] == 'Adriana' | per6[,2] == 'Adriana' | per6[,3] == 'Adriana' | per6[,4] == 'Adriana' | per6[,5] == 'Adriana' | per6[,6] == 'Adriana') & (per6[,1] == 'Mary' | per6[,2] == 'Mary' | per6[,3] == 'Mary' | per6[,4] == 'Mary' | per6[,5] == 'Mary' | per6[,6] == 'Mary') & (per6[,1] == 'Olga' | per6[,2] == 'Olga' | per6[,3] == 'Olga' | per6[,4] == 'Olga' | per6[,5] == 'Olga' | per6[,6] == 'Olga') & (per6[,1] == 'Paty' | per6[,2] == 'Paty' | per6[,3] == 'Paty' | per6[,4] == 'Paty' | per6[,5] == 'Paty' | per6[,6] == 'Paty')),]
head(r11)
##      [,1]      [,2]      [,3]     [,4]   [,5]   [,6]  
## [1,] "Adriana" "Alberto" "Alicia" "Mary" "Olga" "Paty"
## [2,] "Adriana" "Alberto" "Alicia" "Mary" "Paty" "Olga"
## [3,] "Adriana" "Alberto" "Alicia" "Olga" "Mary" "Paty"
## [4,] "Adriana" "Alberto" "Alicia" "Olga" "Paty" "Mary"
## [5,] "Adriana" "Alberto" "Alicia" "Paty" "Mary" "Olga"
## [6,] "Adriana" "Alberto" "Alicia" "Paty" "Olga" "Mary"
tail(r11)
##          [,1]    [,2]   [,3]   [,4]   [,5]      [,6]     
## [10795,] "Romeo" "Paty" "Olga" "Mary" "Adriana" "Laura"  
## [10796,] "Romeo" "Paty" "Olga" "Mary" "Alberto" "Adriana"
## [10797,] "Romeo" "Paty" "Olga" "Mary" "Alicia"  "Adriana"
## [10798,] "Romeo" "Paty" "Olga" "Mary" "Alonso"  "Adriana"
## [10799,] "Romeo" "Paty" "Olga" "Mary" "Anand"   "Adriana"
## [10800,] "Romeo" "Paty" "Olga" "Mary" "Laura"   "Adriana"
resp11 = nrow(r11)
## Hay  10800  permutaciones de grupos de 6 en las que Adriana, Mary, Olga y Paty están en cualquier columna de la 1 a la 6.

12.- ¿En cuántas permutaciones de grupos de 6 se encuentran Adriana, Mary, Olga y Paty, En las columnas 1-4, en las columnas 2-5, y en las columnas 3-6, en ese orden?

r12_1 = per6[which((per6[,1] == 'Adriana' | per6[,2] == 'Adriana' | per6[,3] == 'Adriana' | per6[,4] == 'Adriana') & (per6[,1] == 'Mary' | per6[,2] == 'Mary' | per6[,3] == 'Mary' | per6[,4] == 'Mary') & (per6[,1] == 'Olga' | per6[,2] == 'Olga' | per6[,3] == 'Olga' | per6[,4] == 'Olga') & (per6[,1] == 'Paty' | per6[,2] == 'Paty' | per6[,3] == 'Paty' | per6[,4] == 'Paty')),]
head(r12_1)
##      [,1]      [,2]   [,3]   [,4]   [,5]      [,6]     
## [1,] "Adriana" "Mary" "Olga" "Paty" "Alberto" "Alicia" 
## [2,] "Adriana" "Mary" "Olga" "Paty" "Alberto" "Alonso" 
## [3,] "Adriana" "Mary" "Olga" "Paty" "Alberto" "Anand"  
## [4,] "Adriana" "Mary" "Olga" "Paty" "Alberto" "Laura"  
## [5,] "Adriana" "Mary" "Olga" "Paty" "Alberto" "Romeo"  
## [6,] "Adriana" "Mary" "Olga" "Paty" "Alicia"  "Alberto"
tail(r12_1)
##        [,1]   [,2]   [,3]   [,4]      [,5]    [,6]     
## [715,] "Paty" "Olga" "Mary" "Adriana" "Laura" "Romeo"  
## [716,] "Paty" "Olga" "Mary" "Adriana" "Romeo" "Alberto"
## [717,] "Paty" "Olga" "Mary" "Adriana" "Romeo" "Alicia" 
## [718,] "Paty" "Olga" "Mary" "Adriana" "Romeo" "Alonso" 
## [719,] "Paty" "Olga" "Mary" "Adriana" "Romeo" "Anand"  
## [720,] "Paty" "Olga" "Mary" "Adriana" "Romeo" "Laura"
r12_2 = per6[which((per6[,2] == 'Adriana' | per6[,3] == 'Adriana' | per6[,4] == 'Adriana' | per6[,5] == 'Adriana') & (per6[,2] == 'Mary' | per6[,3] == 'Mary' | per6[,4] == 'Mary' | per6[,5] == 'Mary') & (per6[,2] == 'Olga' | per6[,3] == 'Olga' | per6[,4] == 'Olga' | per6[,5] == 'Olga') & (per6[,2] == 'Paty' | per6[,3] == 'Paty' | per6[,4] == 'Paty' | per6[,5] == 'Paty')),]
head(r12_2)
##      [,1]      [,2]      [,3]   [,4]   [,5]   [,6]    
## [1,] "Alberto" "Adriana" "Mary" "Olga" "Paty" "Alicia"
## [2,] "Alberto" "Adriana" "Mary" "Olga" "Paty" "Alonso"
## [3,] "Alberto" "Adriana" "Mary" "Olga" "Paty" "Anand" 
## [4,] "Alberto" "Adriana" "Mary" "Olga" "Paty" "Laura" 
## [5,] "Alberto" "Adriana" "Mary" "Olga" "Paty" "Romeo" 
## [6,] "Alberto" "Adriana" "Mary" "Paty" "Olga" "Alicia"
tail(r12_2)
##        [,1]    [,2]   [,3]   [,4]      [,5]      [,6]     
## [715,] "Romeo" "Paty" "Olga" "Adriana" "Mary"    "Laura"  
## [716,] "Romeo" "Paty" "Olga" "Mary"    "Adriana" "Alberto"
## [717,] "Romeo" "Paty" "Olga" "Mary"    "Adriana" "Alicia" 
## [718,] "Romeo" "Paty" "Olga" "Mary"    "Adriana" "Alonso" 
## [719,] "Romeo" "Paty" "Olga" "Mary"    "Adriana" "Anand"  
## [720,] "Romeo" "Paty" "Olga" "Mary"    "Adriana" "Laura"
r12_3 = per6[which((per6[,3] == 'Adriana' | per6[,4] == 'Adriana' | per6[,5] == 'Adriana' | per6[,6] == 'Adriana') & (per6[,3] == 'Mary' | per6[,4] == 'Mary' | per6[,5] == 'Mary' | per6[,6] == 'Mary') & (per6[,3] == 'Olga' | per6[,4] == 'Olga' | per6[,5] == 'Olga' | per6[,6] == 'Olga') & (per6[,3] == 'Paty' | per6[,4] == 'Paty' | per6[,5] == 'Paty' | per6[,6] == 'Paty')),]
head(r12_3)
##      [,1]      [,2]     [,3]      [,4]   [,5]   [,6]  
## [1,] "Alberto" "Alicia" "Adriana" "Mary" "Olga" "Paty"
## [2,] "Alberto" "Alicia" "Adriana" "Mary" "Paty" "Olga"
## [3,] "Alberto" "Alicia" "Adriana" "Olga" "Mary" "Paty"
## [4,] "Alberto" "Alicia" "Adriana" "Olga" "Paty" "Mary"
## [5,] "Alberto" "Alicia" "Adriana" "Paty" "Mary" "Olga"
## [6,] "Alberto" "Alicia" "Adriana" "Paty" "Olga" "Mary"
tail(r12_3)
##        [,1]    [,2]    [,3]   [,4]      [,5]      [,6]     
## [715,] "Romeo" "Laura" "Paty" "Adriana" "Mary"    "Olga"   
## [716,] "Romeo" "Laura" "Paty" "Adriana" "Olga"    "Mary"   
## [717,] "Romeo" "Laura" "Paty" "Mary"    "Adriana" "Olga"   
## [718,] "Romeo" "Laura" "Paty" "Mary"    "Olga"    "Adriana"
## [719,] "Romeo" "Laura" "Paty" "Olga"    "Adriana" "Mary"   
## [720,] "Romeo" "Laura" "Paty" "Olga"    "Mary"    "Adriana"
resp12_1 = nrow(r12_1)
resp12_2 = nrow(r12_2)
resp12_3 = nrow(r12_3)
## Hay  720  permutaciones de grupos de 6 en las columnas 1-4,  720  en las columnas 2-5, y  720  en las columnas 3-6, donde se encuentran Adriana, Mary, Olga y Paty.