#[derive(Copy,Clone)]structSet(u16);fnxy(n:i8)->(i8,i8){((n%3)asi8,(n/3)asi8)}implSet{fnhas(&self,n:i8)->bool{(self.0&(1<<n))!=0}fnflip(&self,n:i8)->Self{Self(self.0^(1<<n))}}implDefaultforSet{fndefault()->Self{Set(0b111111111)}}fnattempt(pos:i8,depth:u8,field:Set)->u16{ifdepth==0{return1;}letfield=field.flip(pos);let(mx,my)=xy(pos);(0..9).filter(|&i|field.has(i)).filter_map(|i|{let(x,y)=xy(i);letdx=x-mx;letdy=y-my;ifmatch(dx.abs(),dy.abs()){(0,1)|(1,0)|(1,1)|(1,2)|(2,1)=>true,(0,2)|(2,0)|(2,2)=>{if!field.has((pos+i)/2){true}else{false}}_=>unreachable!(),}{Some(attempt(i,depth-1,field))}else{None}}).sum()}fnmain(){forstartin0..9{forlenin0..=9{println!("start at {}, len {}: {} possibilities",start,len,attempt(start,len,Default::default()));}}}
Look at it go
But note that the "game board" is rotationally symmetric, so there are only three distinctive positions: corner, side, and center.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Rust bruteforce solution
Look at it go
But note that the "game board" is rotationally symmetric, so there are only three distinctive positions: corner, side, and center.