var thearr=new Array(); var savearr=[]; var solarr=new Array(); for (n=0; n<10; n++) { thearr[n] = new Array(); solarr[n] = new Array(); for ( m = 0 ; m < 10 ; m = m + 1 ) solarr[n][m]="0000000000"; } solarr[0][0] = op('or', solarr[0][0], '1', 7); solarr[0][1] = op('or', solarr[0][1], '1', 9); solarr[0][2] = op('or', solarr[0][2], '1', 9); solarr[0][3] = op('or', solarr[0][3], '1', 3); solarr[0][4] = '1111111111'; solarr[0][5] = op('or', solarr[0][5], '1', 2); solarr[0][6] = op('or', solarr[0][6], '1', 3); solarr[0][7] = op('or', solarr[0][7], '1', 1); solarr[0][8] = op('or', solarr[0][8], '1', 7); solarr[0][9] = op('or', solarr[0][9], '1', 7); solarr[1][0] = op('or', solarr[1][0], '1', 9); solarr[1][1] = op('or', solarr[1][1], '1', 7); solarr[1][2] = op('or', solarr[1][2], '1', 2); solarr[1][3] = '1111111111'; solarr[1][4] = op('or', solarr[1][4], '1', 6); solarr[1][5] = op('or', solarr[1][5], '1', 6); solarr[1][6] = op('or', solarr[1][6], '1', 4); solarr[1][7] = op('or', solarr[1][7], '1', 8); solarr[1][8] = op('or', solarr[1][8], '1', 1); solarr[1][9] = op('or', solarr[1][9], '1', 5); solarr[2][0] = op('or', solarr[2][0], '1', 4); solarr[2][1] = op('or', solarr[2][1], '1', 3); solarr[2][2] = '1111111111'; solarr[2][3] = op('or', solarr[2][3], '1', 4); solarr[2][4] = op('or', solarr[2][4], '1', 8); solarr[2][5] = op('or', solarr[2][5], '1', 2); solarr[2][6] = op('or', solarr[2][6], '1', 1); solarr[2][7] = op('or', solarr[2][7], '1', 0); solarr[2][8] = op('or', solarr[2][8], '1', 9); solarr[2][9] = op('or', solarr[2][9], '1', 8); solarr[3][0] = op('or', solarr[3][0], '1', 2); solarr[3][1] = '1111111111'; solarr[3][2] = op('or', solarr[3][2], '1', 9); solarr[3][3] = op('or', solarr[3][3], '1', 2); solarr[3][4] = op('or', solarr[3][4], '1', 6); solarr[3][5] = op('or', solarr[3][5], '1', 0); solarr[3][6] = op('or', solarr[3][6], '1', 8); solarr[3][7] = op('or', solarr[3][7], '1', 5); solarr[3][8] = op('or', solarr[3][8], '1', 6); solarr[3][9] = op('or', solarr[3][9], '1', 0); solarr[4][0] = op('or', solarr[4][0], '1', 4); solarr[4][1] = op('or', solarr[4][1], '1', 1); solarr[4][2] = op('or', solarr[4][2], '1', 2); solarr[4][3] = op('or', solarr[4][3], '1', 4); solarr[4][4] = '1111111111'; solarr[4][5] = op('or', solarr[4][5], '1', 3); solarr[4][6] = op('or', solarr[4][6], '1', 8); solarr[4][7] = op('or', solarr[4][7], '1', 1); solarr[4][8] = op('or', solarr[4][8], '1', 2); solarr[4][9] = '1111111111'; solarr[5][0] = op('or', solarr[5][0], '1', 8); solarr[5][1] = op('or', solarr[5][1], '1', 2); solarr[5][2] = op('or', solarr[5][2], '1', 9); solarr[5][3] = '1111111111'; solarr[5][4] = op('or', solarr[5][4], '1', 1); solarr[5][5] = op('or', solarr[5][5], '1', 3); solarr[5][6] = op('or', solarr[5][6], '1', 0); solarr[5][7] = op('or', solarr[5][7], '1', 1); solarr[5][8] = '1111111111'; solarr[5][9] = op('or', solarr[5][9], '1', 1); solarr[6][0] = op('or', solarr[6][0], '1', 4); solarr[6][1] = op('or', solarr[6][1], '1', 5); solarr[6][2] = '1111111111'; solarr[6][3] = op('or', solarr[6][3], '1', 5); solarr[6][4] = op('or', solarr[6][4], '1', 4); solarr[6][5] = op('or', solarr[6][5], '1', 9); solarr[6][6] = op('or', solarr[6][6], '1', 1); solarr[6][7] = '1111111111'; solarr[6][8] = op('or', solarr[6][8], '1', 6); solarr[6][9] = op('or', solarr[6][9], '1', 9); solarr[7][0] = op('or', solarr[7][0], '1', 0); solarr[7][1] = '1111111111'; solarr[7][2] = op('or', solarr[7][2], '1', 1); solarr[7][3] = op('or', solarr[7][3], '1', 8); solarr[7][4] = op('or', solarr[7][4], '1', 3); solarr[7][5] = op('or', solarr[7][5], '1', 2); solarr[7][6] = '1111111111'; solarr[7][7] = op('or', solarr[7][7], '1', 7); solarr[7][8] = op('or', solarr[7][8], '1', 9); solarr[7][9] = op('or', solarr[7][9], '1', 7); solarr[8][0] = '1111111111'; solarr[8][1] = op('or', solarr[8][1], '1', 1); solarr[8][2] = op('or', solarr[8][2], '1', 0); solarr[8][3] = op('or', solarr[8][3], '1', 8); solarr[8][4] = op('or', solarr[8][4], '1', 1); solarr[8][5] = '1111111111'; solarr[8][6] = op('or', solarr[8][6], '1', 4); solarr[8][7] = op('or', solarr[8][7], '1', 9); solarr[8][8] = op('or', solarr[8][8], '1', 1); solarr[8][9] = op('or', solarr[8][9], '1', 3); solarr[9][0] = op('or', solarr[9][0], '1', 1); solarr[9][1] = op('or', solarr[9][1], '1', 1); solarr[9][2] = op('or', solarr[9][2], '1', 8); solarr[9][3] = op('or', solarr[9][3], '1', 8); solarr[9][4] = op('or', solarr[9][4], '1', 1); solarr[9][5] = op('or', solarr[9][5], '1', 1); solarr[9][6] = op('or', solarr[9][6], '1', 9); solarr[9][7] = op('or', solarr[9][7], '1', 7); solarr[9][8] = op('or', solarr[9][8], '1', 2); solarr[9][9] = '1111111111'; thearr[0][0] = "0111111111"; thearr[0][1] = "0111111111"; thearr[0][2] = "0111111111"; thearr[0][3] = "1111111111"; thearr[0][4] = "1111111111"; thearr[0][5] = "0111111111"; thearr[0][6] = "0111111111"; thearr[0][7] = "0111111111"; thearr[0][8] = "0111111111"; thearr[0][9] = "0111111111"; thearr[1][0] = "0111111111"; thearr[1][1] = "1111111111"; thearr[1][2] = "1111111111"; thearr[1][3] = "1111111111"; thearr[1][4] = "0111111111"; thearr[1][5] = "1111111111"; thearr[1][6] = "1111111111"; thearr[1][7] = "1111111111"; thearr[1][8] = "1111111111"; thearr[1][9] = "1111111111"; thearr[2][0] = "0111111111"; thearr[2][1] = "1111111111"; thearr[2][2] = "1111111111"; thearr[2][3] = "0111111111"; thearr[2][4] = "1111111111"; thearr[2][5] = "1111111111"; thearr[2][6] = "1111111111"; thearr[2][7] = "1111111111"; thearr[2][8] = "1111111111"; thearr[2][9] = "1111111111"; thearr[3][0] = "1111111111"; thearr[3][1] = "1111111111"; thearr[3][2] = "0111111111"; thearr[3][3] = "1111111111"; thearr[3][4] = "1111111111"; thearr[3][5] = "1111111111"; thearr[3][6] = "1111111111"; thearr[3][7] = "1111111111"; thearr[3][8] = "1111111111"; thearr[3][9] = "1111111111"; thearr[4][0] = "0111111111"; thearr[4][1] = "0111111111"; thearr[4][2] = "1111111111"; thearr[4][3] = "1111111111"; thearr[4][4] = "1111111111"; thearr[4][5] = "0111111111"; thearr[4][6] = "1111111111"; thearr[4][7] = "1111111111"; thearr[4][8] = "1111111111"; thearr[4][9] = "1111111111"; thearr[5][0] = "0111111111"; thearr[5][1] = "1111111111"; thearr[5][2] = "1111111111"; thearr[5][3] = "1111111111"; thearr[5][4] = "0111111111"; thearr[5][5] = "1111111111"; thearr[5][6] = "1111111111"; thearr[5][7] = "1111111111"; thearr[5][8] = "1111111111"; thearr[5][9] = "0111111111"; thearr[6][0] = "0111111111"; thearr[6][1] = "1111111111"; thearr[6][2] = "1111111111"; thearr[6][3] = "0111111111"; thearr[6][4] = "1111111111"; thearr[6][5] = "1111111111"; thearr[6][6] = "1111111111"; thearr[6][7] = "1111111111"; thearr[6][8] = "0111111111"; thearr[6][9] = "1111111111"; thearr[7][0] = "1111111111"; thearr[7][1] = "1111111111"; thearr[7][2] = "0111111111"; thearr[7][3] = "1111111111"; thearr[7][4] = "1111111111"; thearr[7][5] = "1111111111"; thearr[7][6] = "1111111111"; thearr[7][7] = "0111111111"; thearr[7][8] = "1111111111"; thearr[7][9] = "1111111111"; thearr[8][0] = "1111111111"; thearr[8][1] = "0111111111"; thearr[8][2] = "1111111111"; thearr[8][3] = "1111111111"; thearr[8][4] = "1111111111"; thearr[8][5] = "1111111111"; thearr[8][6] = "0111111111"; thearr[8][7] = "1111111111"; thearr[8][8] = "1111111111"; thearr[8][9] = "1111111111"; thearr[9][0] = "0111111111"; thearr[9][1] = "1111111111"; thearr[9][2] = "1111111111"; thearr[9][3] = "1111111111"; thearr[9][4] = "1111111111"; thearr[9][5] = "1111111111"; thearr[9][6] = "1111111111"; thearr[9][7] = "1111111111"; thearr[9][8] = "1111111111"; thearr[9][9] = "1111111111"; save(); // arr = thearr.slice(); function setto(orig, pos, newc) { return (pos>0?orig.substring(0,pos-1):"")+newc+orig.substring(pos+1); } function howami() { var i,j; var okay=true; var allsingle=true; for (i=0; i<10; i++) for (j=0; j<10; j++) { var l=0; for (k=0; k<10; k++) if (thearr[i][j].substring(k,k+1) == "1" && true) l++; allsingle = allsingle && l < 2; if (whop("and", thearr[i][j], solarr[i][j]) == "0000000000") { okay = false; ihm = document.getElementById("c"+i+"/"+j).innerHTML; ihm = ihm.replace(/gray/g, "red"); ihm = ihm.replace(/blue/g, "red"); document.getElementById("c"+i+"/"+j).innerHTML = ihm; } } if (okay) alert(allsingle?"Sie haben eine Lösung gefunden!":"Alles in Ordnung! In jedem Kästchen steht noch zumindest eine Ziffer, die Teil einer Lösung ist."); else alert("Sie haben ein bisschen zu viel ausgeschlossen - siehe rot markierte Kästchen."); } function whop(andor, a, b) { res = ""; for (n=0; n<=9; n++) res += (andor == "and"? (a.substring(n,n+1) =="1" && b.substring(n,n+1) == "1"? "1" : "0") : (a.substring(n,n+1) =="1" || b.substring(n,n+1) == "1"? "1" : "0")); return res; } function op(andor, a, b, pos) { res = ""; for (n=0; n<=9; n++) res += (n == pos? (andor == "and"? (a.substring(n,n+1) =="1" && b == "1"? "1" : "0") : (a.substring(n,n+1) =="1" || b == "1"? "1" : "0")) : a.substring(n,n+1)); return res; } function restore() { // var setsomething = false; for (r=0; r<10; r++) { thearr[r] = savearr[r].slice(); for (c=0; c<10; c++) for (d=0; d<10; d++) { fat = ((thearr[r][c]).substring(d,d+1) =="1"); if (obj = document.getElementById("n"+r+"/"+c+"/"+d)) { obj.style.fontSize= fat?"10px":"8px"; obj.style.fontWeight=fat?"bold":"lighter"; obj.style.color=fat?"blue":"gray"; // setsomething = true; } } } // if (setsomething) alert("set something."); } function save() { for (r=0; r<10; r++) savearr[r] = thearr[r].slice(); } function invert(obj, row, col, n) { if (obj.style.fontSize=="10px") { obj.style.fontSize="8px"; obj.style.fontWeight="lighter"; obj.style.color="gray"; thearr[row][col] = op("and", thearr[row][col], "0", n); } else { obj.style.fontSize="10px"; obj.style.fontWeight="bold"; obj.style.color="blue"; thearr[row][col] = op("or", thearr[row][col], "1", n); } }