//
Vapaa javascript -sudoku peli.
var sudokuconf = "000081000600000400070000000020400000000300500019000000500640000800000010000000002"; var sudokusol = "254781963698253471173964285725496138486317529319825746531642897862579314947138652"; function gt(x,y) { var item = ((x-1)*9 + y) - 1; var num = sudokuconf.substr(item,1); if (num != '0') return ''; else return ''; } document.write (''); function locate(item) { for(i=0;i < document.ysudoku.elements.length;i++) if (document.ysudoku.elements[i].name == item) return i; return -1; } function clearSudoku() { for (i=0; i<81; i++) if (sudokuconf.substr(i ,1) == '0') document.ysudoku.elements[ i ].value = ''; else document.ysudoku.elements[ i ].value = sudokuconf.substr(i ,1); } function validateSudoku () { for (i=0; i<81; i++) { col = (i % 9 + 1); row = parseInt(i / 9 + 1); value = document.ysudoku.elements[i].value; if (value != '1' && value != '2' && value != '3' && value != '4' && value != '5' && value != '6' && value != '7' && value != '8' && value != '9') { alert('Invalidityyppi tai numero rivissä '+row+' , sarake '+col+' !'); return; } if (value != sudokusol.substr(i ,1)) { alert('Ikävä kyllä toisti numeroa rivissä '+row+' , sarake '+col+' !'); return; } } } function solveSudoku() { for (i=0; i<81; i++) document.ysudoku.elements[ i ].value = sudokusol.substr(i ,1); } function anotherSudoku() { document.location.reload(); } //