18/09/23 18:58:40.06 edPyfcCi.net
same <- function(x,base){
f=function(a,b=base){ # is equal to base
all(a==b)
}
mat=rbind(rn(x),rn(rev(x))) # rotation and/or symmetric conversion
any(apply(mat,1,f))
}
mat=perm1
tail(perm1)
exvar <- function(row,mat=perm1){
var=rn(mat[row,])
n.var=nrow(var)
idx=NULL
for(i in 1:n.var){
idx=c(idx,which(apply(mat,1,function(x) same(x,var[i,]))))
}
min(idx)
}
index=sapply(1:nrow(perm1),exvar) # several minutes for k=3
re=perm1[unique(index),]
re
print(matrix(c("赤","白","青")[re],ncol=3*k),quote=F)