# Machine Problem 3, due Mar 31

## Assignment:

Consider the following series of figures:

```0    1        2
[]     [][]           [][]  [][]
[][]           [][]  [][]
[]             []    []
[][]  [][]
[][]  [][]
[]    []
[][]
[][]
[]
```

Each cell in the figure is either two blanks or it is composed of a pair of square brackets []. The following induction rule is used to compose each figure:

• The level zero figure occupies one cell

• The level n figure occupies a space 3n cells wide by 3n cells high. In this space are 5 level n–1 figures.

Write a program to plot the largest figure that will fit on your screen, centered on the screen.

## Suggestions:

This problem cannot be solved without writing a recursive subroutine to plot an order n figure at some coordinates on the screen. You should separate that problem from:

a) the problem of centering the figure on the screen. Do that later.

b) the problem of finding the largest order figure that will fit on the screen. Do that last.

A subsidiary problem will show up: Computing 3 to the n. Do this by repeated multiplication by 3, and most definitely, do not use any multiply subroutine. Rather, just use the appropriate add-and-shift instruction.

When you test your routine, try different window sizes. Once it seems to work pretty well, try setting your window's font size tiny and running the program in a huge window.

### Requirements:

• Your source file must be titled with mp3.a and your name. Failure to follow this requirement will result in your assignment being ignored. We, the instructor and teaching assistants, will not engage in detective work to determine who to credit with an assignment.

• You must use the on-line coursework submission tools, as you did form MP1, submitting the file mp3.a for the course c_060 in the submission directory mp3.

• Your code must be well formatted and readable. This means approprite use of tabs and other forms of whitespace andappropriate names for labels that are suggestive of the program structure.

• Your code must be well commented. This is not merely a matter of writing lots of comments, but a matter of comments that motivate and explain the code. Comments that merely restate what each instruction does are bad.
• Your code must make appropriate use of subroutines, where any and all activation records and parameters must be clearly documented, and where subroutines should be clearly set off from each other by appropriate comments and or subtitles.