For the bored
2007-08-09
- Open MS Excel. Other spreadsheets might work, but you may have to customise the instructions (notes for OOo Calc after the fold).
- Enter 1 into the top-left cell. Copy it down as far as you like (use the little square on the corner of the frame around the cell when it's selected). Then copy it (just A1, not the rest of the column) across as far as you like.
- Into B2, enter the formula: =mod(A2+B1,2). This is most easily by done by selecting B2 then pressing the following keys:
= m o d ( [Left Arrow] + [Up Arrow] , 2 ) [Return]
- Copy that formula down to the row where your '1's end, and across to the last column. Note that Excel's drag copy can only stretch in one direction at a time: use the little box to pull the formula down, then use it again to copy the new selection across.
- Select the whole sheet (Ctrl+A) and double-click on the border between any two column headers. Alternatively, with the sheet selected drag one of those borders back and forth until your cells are as wide as they are tall.
- Finally, with the whole sheet selected choose 'Conditional Formatting...' from the Format menu. Make your condition that 'cell' 'is equal to' '1' and assign a background colour.
Hey presto, a Sierpinski Triangle. Approximately.
Compatibility notes: I'm using Excel 2000. Newer versions should probably work without change.
In OpenOffice.org Calc, you can't use the drag-copy to create your '1's because it auto-increments them (Excel does this too if you drag-copy a selection that includes other formulas). I'm not sure what the quick way is. Calc uses semi-colons to separate function arguments, so the formula for B2 should be =mod(A2+B1;2). Also, you must define a style with a background colour before you try to turn on the conditional formatting; it can't be done from inside the conditional formatting dialog.
Comments