3 ms·
Can someone help me understand why it has to look like this? for(var i=0;i<9;i++){for(var k=0;k<i;k++){for(var m=0;m<k;m++){ for(var j=0;j<9;j++){if(i
by nerdponx 9y ago
Can someone help me understand why it has to look like this?
for(var i=0;i<9;i++){for(var k=0;k<i;k++){for(var m=0;m<k;m++){
for(var j=0;j<9;j++){if(i!=j && k!=j && m!=j){for(var l=0;l<j;l++){if(i!=l && k!=l && m!=l){for(var n=0;n<l;n++){if(i!=n && k!=n && m!=n){
pos=""
dummy_moves=Array()
for(var a=0;a<9;a++){
if(a==i || a==k || a==m){
pos+="1"
dummy_moves.push(0)
} else if(a==j || a==l || a==n){
pos+="2"
dummy_moves.push(0)
} else {
pos+="0"
dummy_moves.push(s[3])
}
}
add_box(pos,dummy_moves)
}}} }}}}}}
- tyingq 9y agocontinue; could reduce the depth a bit, but it's still gnarly. https://gist.github.com/anonymous/f3607a28a4c8ad1322f13a2d10f28b5e https://gist.github.com/anonymous/f3607a28a4c8ad1322f13a2d10...
- pronoiac 9y agoI have a ridiculous urge to refactor this. It's enumerating all of the boards, legal or not. Judging by the letters, it's doing one player's moves at first, in a way that's trying to avoid repeats. If I were to do this, I'd have, well, menace_x and menace_o, and build move n from move n-1. Depth-first would also work, really, as we're talking about only 300-ish boards.