fredrsf,
Похоже на задачу как расставить ладьи на шахматной доске, чтобы они не били друг друга? ))) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> td{ height: 22px; width: 22px; text-align: center; } </style> </head> <body> <script language="JavaScript" type="text/javascript"> for (var m = [], l = 10, b = ["background-color: #FFFF00;", "background-color: #00FF00;", "background-color: #FF0000;"], t = document.createElement("table"), c = 0; c < l; c++) { var tr = t.insertRow(c); m[c] = c; for (var s = 0; s < l; s++) tr.insertCell(s).style.cssText = b[0] } document.body.appendChild(t); c = 0; function go() { for (s = 0; s < l; s++) t.rows[c].cells[s].style.cssText = b[1]; r = Math.floor(Math.random() * m.length); r = m.splice(r, 1); t.rows[c].cells[r].style.cssText = b[2]; for (s = ++c; s < l; s++) t.rows[s].cells[r].style.cssText = b[1]; c < l && setTimeout(arguments.callee, 600) }; </script> <input type="button" name="" value="go" onclick="go()"/> </body> </html> |
рони,
на сколько я помню там ферзи, а не ладьи ) когдато не верил что она решаема ) |
fredrsf,
<table> <tr> <td> <input type="checkbox" name="line1" value="1"> <input type="checkbox" name="line1" value="2"> <input type="checkbox" name="line1" value="3"> <input type="checkbox" name="line1" value="4"> <input type="checkbox" name="line1" value="5"> </td> </tr> <tr> <td> <input type="checkbox" name="line2" value="1"> <input type="checkbox" name="line2" value="2"> <input type="checkbox" name="line2" value="3"> <input type="checkbox" name="line2" value="4"> <input type="checkbox" name="line2" value="5"> </td> </tr> <tr> <td> <input type="checkbox" name="line3" value="1"> <input type="checkbox" name="line3" value="2"> <input type="checkbox" name="line3" value="3"> <input type="checkbox" name="line3" value="4"> <input type="checkbox" name="line3" value="5"> </td> </tr> <tr> <td> <input type="checkbox" name="line4" value="1"> <input type="checkbox" name="line4" value="2"> <input type="checkbox" name="line4" value="3"> <input type="checkbox" name="line4" value="4"> <input type="checkbox" name="line4" value="5"> </td> </tr> <tr> <td> <input type="checkbox" name="line5" value="1"> <input type="checkbox" name="line5" value="2"> <input type="checkbox" name="line5" value="3"> <input type="checkbox" name="line5" value="4"> <input type="checkbox" name="line5" value="5"> </td> </tr> </table> <script> var checkboxes = (document.getElementsByTagName('input')); for(var i=0;i<checkboxes.length;i++){ checkboxes[i].onclick = function (){ var checkboxes = (document.getElementsByTagName('input')); for(var i=0;i<checkboxes.length;i++){ if((this.name!=checkboxes[i].name || this.value!=checkboxes[i].value) && (this.name==checkboxes[i].name || this.value==checkboxes[i].value)){ checkboxes[i].disabled = !!this.checked; } } } } </script> так надо ? |
DooMer,
Простая растановка ферзей на поле любой величины ))) Давненько не брал я в руки шашек. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style type="text/css"> td{ height: 22px; width: 22px; text-align: center; } </style> </head> <body> <script language="JavaScript" type="text/javascript"> for (var m = [], l = 8, b = ["background-color: #FFFF00;", "background-color: #00FF00;", "background-color: #FF0000;"], t = document.createElement("table"), c = 0; c < l; c++) { var tr = t.insertRow(c); m[c] = []; for (var s = 0; s < l; s++) { tr.insertCell(s).style.cssText = b[0]; m[c][s] = s } } document.body.appendChild(t); c = 0; function go() { f = []; for (s = 0; s < l; s++) if (m[c][s] >= 0) { t.rows[c].cells[s].style.cssText = b[1]; f.unshift(m[c][s]) } c++; if (f.length) { r = Math.floor(Math.random() * f.length); r = f.splice(r, 1)[0]; t.rows[c - 1].cells[r].style.cssText = b[2]; m[c - 1][r] = -1; s = c; for (a = 0; s < l; s++) { t.rows[s].cells[r].style.cssText = b[1]; m[s][r] = -1; a++; if (r - a >= 0) { t.rows[s].cells[r - a].style.cssText = b[1]; m[s][r - a] = -1 } if (r + a < l) { t.rows[s].cells[r + a].style.cssText = b[1]; m[s][r + a] = -1 } } } c < l && setTimeout(arguments.callee, 600) }; </script> <input type="button" name="" value="go" onclick="go()"/> </body> </html> |
Часовой пояс GMT +3, время: 01:06. |