「安倍が死ねば、日本は幸せになる」という命題があるとき、安倍が死んでないならこの命題は必ず真 at MATH
[2ch|▼Menu]
203:132人目の素数さん
18/07/31 12:11:17.41 AXaAgLMZ.net
rot <- function(row,col,n=8){ # position after 90 degree rotation
c(col,n-row+1)
}
rota <- function(x){ # 90 degree rotation
n=length(x)
re=numeric(n)
for(i in 1:n){
tmp=rot(i,x[i],n)
re[tmp[1]]=tmp[2]
}
re
}
# ratete 90 degree four times
rotate <- function(x){
r1=rota(x)
r2=rota(r1)
r3=rota(r2)
rx=rbind(x,r1,r2,r3)
rownames(rx)=NULL
return(rx)
}
b2v <- function(x){
ret=unique.matrix(rbind(x,rotate(x),rotate(rev(x))))
rownames(ret)=NULL
ret
}
is.var <- function(x,y){ # x: base, y : variation of x ?
v=b2v(x)
nv=nrow(v)
for(i in 1:nv){
if(all(v[i,]==y)) return(TRUE)
}
return(FALSE)
}
uniQ <- function(M){ # check firt row vs the others
n=nrow(M)
uniq=numeric(n)
for(i in 1:n){
uniq[i]=!is.var(M[1,],M[i,]) # is no variant?
}
M=rbind(M[which(uniq==1),],M[1,]) # append 1st row at last
return(M) # not the final answer
}
M=N_Queen(9)
while(nrow(M)!=nrow(uniQ(M))){
M=uniQ(M)
}
M


次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

1922日前に更新/62 KB
担当:undef