Piet (Mondrian)'s Puzzle
Piet, 9625

(It finally works!)

The people demanded it, so here it is. This is an extremely naive solution (essentially the same as the loose upper bounds on the OEIS page): it divides each square into just two rectangles.

This gist contains the details in two files:


The program's output (using npiet v1.3) for all required inputs. Note that I only captured stdout, so the ? is the input prompt, followed immediately by the output score, then the grid.
The "pseudo-assembly" source I used to plan out the program.




Explanation

This program takes a single number N as input. If the number is odd, the score is the number; if even, the score is twice the number.

After outputting the score, the rest of the left-hand side of the program is spent filling the stack with five lots of the following information:


The grid width (which is N)
A number of lines to print
A character to print across the grid (either _ or space)
A character to print at each edge of the grid (either space or |)


The right-hand side of the program takes each set of four values and prints out that part of the grid.