> Or did you introduce a rule that the input has to be a square? Sorry, I missed this earlier, but as per my submission a few minutes ago I raise an exception if it's non-square, but only to pass the unit tests. Otherwise I see no problem with this. > For larger sheets my system (512M) starts to swap too much. > Probably I should have used a singe array instead of three dimensional > arrays of arrays... Very interesting to see other solutions. So far I seem to be the only one not to have modelled the grid explicitly, allocating an array only for the output. Tried 1024x1024 just now (took 4 minutes - how about you?) and I'll give your tests a try. Mine seems to be the most verbose though... Mike Burrows