## Seeing Digits

Each number in a grid represents how many other numbers can be seen from that square (as a queen in chess, horizontally, vertically, and diagonally, only as far as the first digit in that line.)  Here is a grid using the numbers 1 thru 5:

 3 3 5 4 1 2 2

Meet these requirements for the following scenarios.  Place at least one of each of the numbers 1 to N into

1. the smallest-area rectangle.
2. an NxN square, achieving the smallest sum.
3. an NxN square, achieving the largest sum.

For example, if N=6, at least one each of 1,2,3,4,5,6 must be in the grid.  Let N range from 1 to 8.

Source: Original.

Kirk's Results:
```Part #1 - Smallest Area Rectangles

1 : 1 x 2 = 2
1 1

2 : 1 x 3 = 3
1 2 1

3 : 2 x 3 = 6
2 3 1
2 _ _

4 : 3 x 3 = 9
2 3 _
4 _ 2
1 _ _

5 : 2 x 5 = 10
3 4 2 _ _
3 5 _ _ 1

6 : 3 x 5 = 15
3 5 3 _ 1
5 6 _ _ _
3 4 _ 2 _

7 : 3 x 6 = 18
3 5 5 4 _ 1
5 7 6 4 _ _
3 5 _ _ 2 _

8 : 3 x 7 = 21
3 5 5 5 4 _ 1
5 8 7 6 4 _ _
3 5 5 _ _ 2 _
```
```Part #2 - Minimize sum on an NxN square where there is at least one of each
number 1 ... N

3 : 3 x 3 = 9, smallest sum = 8
2 2 _
3 _ _
1 _ _

4 : 4 x 4 = 16, smallest sum = 12
2 3 _ _
4 _ 2 _
1 _ _ _
_ _ _ _

5 : 5 x 5 = 25, smallest sum = 18
2 _ _ _ _
3 5 _ _ 1
4 _ 2 _ _
1 _ _ _ _
_ _ _ _ _

6 : 6 x 6 = 36, smallest sum = 24
3 5 2 _ _ _
4 6 _ _ _ _
2 _ _ _ _ _
_ _ _ _ 1 _
_ 1 _ _ _ _
_ _ _ _ _ _
```
Adrian matched Kirk's sums for 3-5 and also found these next two solutions.
```7 : 7 x 7 = 49, smallest sum = 33
_ _ _ 1 _ _ _
_ 4 _ 6 _ 3 _
2 _ _ _ _ _ _
_ 5 _ 7 _ 3 _
_ _ _ _ _ _ _
_ 2 _ _ _ _ _
_ _ _ 1 _ _ _

8 : 8 x 8 = 64, smallest sum = 45
1 _ _ _ _ _ _ _
_ _ _ 3 _ 4 _ 3
_ _ _ _ _ _ _ _
_ _ 1 8 _ 7 _ _
_ _ _ _ _ _ 2 _
_ 2 _ 5 _ 6 _ _
_ _ _ _ 2 _ _ _
_ _ _ _ _ _ _ 2
```
Joseph DeVincentis sent these solutions for part 3.
```Part #3 - Maximize sum on an NxN square where there is at least one of
each number 1 ... N (with a maximum digit of N)

3 : largest sum = 8
2 2 _
3 _ _
1 _ _

4 : largest sum = 20
_ 4 2 _
3 4 _ _
4 _ _ 2
1 _ _ _

5 : largest sum = 40
2 _ _ _ _
4 5 _ 4 2
_ 5 5 4 _
3 _ 5 _ _
_ _ 1 _ _

6 : largest sum = 82
2 _ _ _ _ _
4 6 _ 5 4 3
5 6 6 6 6 _
_ 6 6 _ _ 4
3 _ 6 _ _ 3
_ _ 1 _ _ _
```
Update 7/28/2006. Kirk found these solutions which have slightly higher sums.
```4 : 4 x 4 = 16, sum = 24
3 4 3 _
3 _ _ _
4 _ 4 2
1 _ _ _

5 : 5 x 5 = 25, sum = 50
3 4 5 _ 2
5 _ _ _ 4
5 _ _ 5 5
1 _ _ _ _
_ _ 4 4 3

6 : 6 x 6 = 36, sum = 88
3 _ 5 _ 5 3
4 _ _ 6 6 5
5 _ _ 6 6 _
1 _ _ _ _ _
_ _ 6 6 6 4
_ 2 _ 5 4 _
```
Kirk also solved some of part 3, allowing for any numbers to be in the NxN grid. I'd intended for the max number to be N, but I understand this interpretation, too.
```Part #3 - Maximize sum on an NxN square where there is at least one of
each number 1 ... N

3 : 3 x 3 = 9, largest sum = 12
2 3 _
4 _ 2
1 _ _

4 : 4 x 4 = 16, largest sum = 34
3 4 _ _
5 6 4 1
4 5 _ _
2 _ _ _

5 : 5 x 5 = 25, largest sum = 70
3 5 _ 2 _
5 7 5 _ _
5 8 6 _ 1
5 7 4 _ _
3 4 _ _ _

6 : 6 x 6 = 36, largest sum = 122
3 5 4 _ _ _
5 8 7 4 _ _
5 8 8 6 _ 1
5 8 8 5 _ _
5 7 6 _ _ _
3 5 _ 4 2 _
```

Mail to Ken