You are on page 1of 1

rm(list = ls())

a=matrix(NA,36,2)
a[,1]=rep(1:6,each=6)
a[,2]=rep(1:6,6)
a=cbind(a,rowSums(a),rowSums(a)%%6)
# count(a[,4])
# count(a[,3])
b=matrix(NA,216,3)
b[,1]=rep(1:6,each=36)
b[,2]=rep(a[,1],6)
b[,3]=rep(a[,2],6)
b=cbind(b,rowSums(b),rowSums(b)%%6)
# count(b[,5])
# count(b[,4])
# c=unique(b[,4])

#if dice are similar


x=rep(1:6,6:1)
y=c(1:6,2:6,3:6,4:6,5:6,6)
Ax=matrix(c(x,y,x+y,(x+y)%%6),length(x),4)
count(Ax[,4])
# Site
# http://davetang.org/muse/2013/09/09/combinations-and-permutations-in-r/
library(gtools)
library(plyr)
B=combinations(6,3,1:6,repeats.allowed = T)
C=cbind(B,rowSums(B))
Bx=cbind(B,rowSums(B),rowSums(B)%%6,rowSums(B)%%12)
count(C[,4])
D=unique(C[,4])

You might also like