function fontsize (object, value) { switch (value.length) { case 1: object.style.paddingTop = "0px"; object.style.fontSize = "30px"; break; case 2: object.style.paddingTop = "3px"; object.style.fontSize = "26px"; break; case 3: object.style.paddingTop = "5px"; object.style.fontSize = "22px"; break; case 4: object.style.paddingTop = "8px"; object.style.fontSize = "16px"; break; case 5: object.style.paddingTop = "9px"; object.style.fontSize = "14px"; break; } object.value = value; } function checkMySudoku() { var theSec=new Sudoku(); anzSols=0; for (var i=0; i<81; ++i) { var o=document.getElementById("i"+i) var v=o.value if (v>="1" && v<="9" && o.readOnly == true) { theSec.vlu(i, parseInt(v)); } } var rsp=theSec.sss(); var ans="

No solution<\/p>"; if (anzSols > 0) { ans=bs.cit(); } else { alert ("Ungültiges Sudoku Puzzle"); } } function checkMySudoku2() { var theSec=new Sudoku(); anzSols=0; for (var i=0; i<81; ++i) { var o=document.getElementById("i"+i) var v=o.value if (v>="1" && v<="9") { theSec.vlu(i, parseInt(v)); } else { alert (unescape("Sudoku Puzzle ist nicht korrekt gel%F6st.")); return; } } var rsp=theSec.sss(); var ans="

No solution<\/p>"; if (anzSols > 0) { alert(unescape("Herzlichen Gl%FCckwunsch. Sie haben das Sudoku erfolgreich gel%F6st.%0AKlicken Sie OK um am Wettbwerb teil zu nehmen.")); document.formsudoku.submit(); } else { ans=bs.cit(); alert (unescape("Sudoku Puzzle ist nicht korrekt gel%F6st.")); } } function solveMySudoku() { var style; var theSec=new Sudoku(); anzSols=0; for (var i=0; i<81; ++i) { var v=document.getElementById("i"+i).value var o=document.getElementById("i"+i) if (v>="1" && v<="9" && o.readOnly == true) { theSec.vlu(i, parseInt(v)); } } var rsp=theSec.sss(); var ans="

No solution<\/p>"; if (anzSols > 0) { var ans=""; var data = bs.gdt (); for (var y=0; y<9; ++y) { ans=ans+"" for (var x=0; x<9; ++x) { var style = ""; if (y == 2 || y == 5) style = "border-bottom:4px solid black; "; if (x == 2 || x == 5) style += "border-right:4px solid black; "; ans=ans+"" + mct(data[x+y*9]) + "<\/td>"; } ans=ans+"<\/tr>"; } ans = ""+ans+"<\/table>"; ans = ans + "Fenster schließen"; } solution = window.open("", "Lösung", "width=330,height=330,left=100,top=200"); solution.document.write("" + ans + "") solution.focus(); } //////////////////// END OF PUBLIC INTERFACE ////////////////////////////// var bs=new Sudoku(); var anzSols; // First, create the custom object "Sudoku" function Sudoku () { var size = 81; this.data=new Array(); for (var i=0; i < size; ++i) { this.data[i]=0; } } /* Some help functions */ function allo(val) { var cc=new Array; var n=0; for (var i=1; i<=9; ++i) { if (((1<=a) { a=v; p=i; } } } return p; } Sudoku.prototype.mn=meed; function vl(pos, val) { var x=pos%9; var y=Math.floor(pos/9); var x0=Math.floor(x/3)*3; var y0=Math.floor(y/3)*3; var add=(1< 0) { document.getElementById("i"+i).style.background = "#FFDDDD"; } else { document.getElementById("i"+i).style.background = "#FFFFFF"; } } x1 += " " + c1 x2 += " " + c2 } } Sudoku.prototype.cit=ci; function sok() { for (var i=0; i<81; ++i) { if ((this.data[i] & 1022)==1022) { return false; } } return true; } Sudoku.prototype.ok=sok; function sv() { for (var i=0; i<81; ++i) { if ((this.data[i] & 1)==0) return false; } return true; } Sudoku.prototype.svd=sv; function ss() { while (this.ok()) { if (this.svd()) { if (1<++anzSols) return this; for (var ia=0; ia<81; ++ia) { bs.data[ia]=this.data[ia]; } return null; } var p=this.mn(); if (p<0) return null; var l=allo(this.data[p]); if (l.length<1) return null; for (var i=1; i