"Lights Switched" toggles the cell selected and its immediate orthogonal neighbours.
"Lights On Diagonally" does exactly the same except that diagonal neighbours are toggled on or off, ie, if a neighbour is on it is turned off.
Select an "N x N" grid size to display that grid for examination.
Offer a lowest switching sequence for each grid (for the 3 x 3 it takes 5).
(In reply to
to Brian by pcbouhid)
Rather than try to copy the source code of each matrix go to View Source/View Page Source or whatever is available with your browser.
Javascript writes the numeric grid size links and then refers the one chosen to a new function which builds the grid "on the fly". This script does not change the HTML that comes down to your computer as such but makes the necessary changes somewhere in memory; when you select a different grid you create a change in memory (at least that's my understanding the process).
My browser suggests that "Lights On Diagonally" begins on line 91 and goes down to line 269. All of that needs to be embodied in HTML, HEAD and BODY tags.
Better still I'll send you my HTML page.
|
Posted by brianjn
on 2009-07-16 22:17:06 |