After writing the starting coordinates of each row to `IMAGE`

, a sequence of 30 pixels is generated. After each row is finished, the current Y coordinate is restored from `BAK`

and incremented.

Node 5 stores the Y coordinate, saving the `SWP/ADD 1/SAV`

delay at the end of each row.

Nodes 5 and 8 take turns writing values to the output. Since node 5 writes both the first and last value in each row, node 8 has to wait one cycle at the end of the row to avoid getting out of order.

Solution by rednax1206.

The X value is stored in `ACC`

and the Y value is stored in `BAK`

. Clever use of subtraction and addition determines the next X value.

This is similar to the solution for Image Test Pattern 1, but nodes 5 and 8 swap colors on alternate rows.

For each rectangle, node 2 passes the starting X value and the width straight to node 5. For each row of the current rectangle, node 2 passes the current Y value and the number of rows remaining to node 5.

For each rectangle, node 5 stores the starting X value and 6 minus the width, to allow unrolling the loop in node 9. (No width values in the input are greater than 6.) For each row of the current rectangle, node 5 passes the starting X value, the current Y value, and 6 minus the width to node 9.

For each row, node 9 passes the starting X value, the current Y value, and a sequence of the correct width to the output.

Optimization by CaitSith2.

For each rectangle, the starting X value and the width are passed through node 4 instead of tying up node 2 for four extra cycles.

Solution by gmnenad.

This solution is almost theoretically optimal; it takes at least 551 cycles to output 139 pixels in 39 lines. Optimizations include:

- Node 8 links node 4 (Y,H) and output node 9
- Node 5 processes X and W while node 4 processes Y and H, so that only Y takes the longer path through node 8
- Node 5 saves a
`NEG`

instruction by calculating`ACC = 6-UP`

instead of`ACC = -(UP-6)`

- The
`JRO UP`

instruction in node 9 is moved before all the output instructions, giving nodes 4 and 5 two more cycles to calculate the next line

All the computation takes place in node 9. For each column, the X value is stored in `BAK`

and the starting Y value (18 minus the column height) is read into `ACC`

. A pixel is drawn and the Y value is incremented until it reaches the bottom of the screen, then the X value is incremented and a new starting Y value is read from the input.

Node 6 generates Y values, starting at the bottom of the screen for each column and moving upward until the column is finished.

Node 8 generates X values, starting at the left of the screen and moving one pixel to the right after each column is finished.

Node 9 does nothing but write values to the output. Since it is only idle 3% of the time (nodes 6 and 8 take an additional 3 cycles to reset in between columns), this solution is almostâ€“but not quiteâ€“theoretically optimal.

Solution by CaitSith2.

Node 1 makes 2 copies of the input.

One copy gets fed into node 5, which determines which Y value the line is to start drawing at.

Node 8 then feeds the Y to node 9, and increments Y.

Node 2 determines if Node 6 should increment its X value prior to Node 6 feeding its X value to node 9.

Node 9 takes X, Y and draws the histogram lines, one pixel at a time.