I'm trying to generate square grid templates to drill holes on a plate for a fragmentation experiment. I have three different problems that I'm not finding a way to solve using the documentation, they are:
- I need to keep track of the order in which the cells would be
drilled, but I couldn't find a way to do this using
SparseArray
. - I which to apply a conditional formating rule where the cells that
would be drilled have a dark gray background and white number, but
thus far all my attempts to use conditions with
Grid
options failed. - I need to be able to generate and print a large number of
these templates, I would usually use
Table
orTableForm
to do this, but since I don't know a way to divide the array into a matrix/grid I'm not getting an output that is printer friendly.
The basics of the program is this:
GridTemplate[msize_, ndrill_] := Module[{ms, nd},
(*creates a square grid template of size msize and number of drilling holes ndrill*)
ms = msize;
nd = ndrill;
Grid[SparseArray[# -> 1 & /@ Table[RandomInteger[{1, ms}, 2], {nd}]], Frame -> All]]