Using only printable ASCII (hex codes 20 to 7E), write a square N×N core program without comments that is surrounded by 4 more layers, creating a (N+8)×(N+8) square program (N > 0). For N = 3 the layout (to be replaced by actual code) looks like this:
44444444444
43333333334
43222222234
43211111234
4321CCC1234
4321CCC1234
4321CCC1234
43211111234
43222222234
43333333334
44444444444
- The C's represent the core 3×3 program.
- The 1`s represent the first layer, the 2's represent the second layer, etc.
The program always takes a string of space separated integers such as 0 -1 31 -1 2 2 2
via stdin or similar (it should just be the plain numbers, no quotes or brackets or anything). The output depends on what parts of the layout were run.
There are five ways to run the program (newlines are included in the run). Each does something different to the list:
Run just the core:
CCC CCC CCC
This computes the maximum of the absolute values of the input list elements, and prints
CORE
on a new line that many times. If the max is 0 nothing is output (a newline is fine).The output for
0 -1 31 -1 2 2 2
would beCORE CORE ...
31 times.
Run the core with layer 1:
11111 1CCC1 1CCC1 1CCC1 11111
This outputs the average (arithmetic mean) of the list values to standard floating point precision.
- The output for
0 -1 31 -1 2 2 2
would be 35 / 7 =5
(5.0
is fine).
- The output for
Run the core with layers 1 and 2:
2222222 2111112 21CCC12 21CCC12 21CCC12 2111112 2222222
This outputs a space separated list of the input list reversed.
- The output for
0 -1 31 -1 2 2 2
would be2 2 2 -1 31 -1 0
.
- The output for
Run the core with layers 1, 2, and 3 (the pattern should be obvious).
This outputs a space separated list of the sorted input list.- The output for
0 -1 31 -1 2 2 2
would be-1 -1 0 2 2 2 31
.
- The output for
Run the core with layers 1, 2, 3, and 4.
This outputs a space separated list of the input list with duplicates removed, the ordering doesn't matter.- The output for
0 -1 31 -1 2 2 2
could be-1 0 2 31
.
- The output for
All output is to stdout or a similar alternative.
Only these 5 layout combinations have specified behavior.
Notes
- Comments are not allowed in the core or layers or combinations thereof. Code that is a no-op or does nothing constructive does not count as a comment.
- Remember that the core can have any (positive) N×N dimensions, but the layers are only one character thick.
- You may assume the input has no leading or trailing spaces and exactly one space between numbers. It will always contain at least one number. (The output lists should be formatted like this too.)
- You may assume the list and calculations necessary for output won't have values that overflow (or underflow) your integers (as long as their max is something reasonable like 216).
Scoring
Writing this program normally would be easy. Writing it with a small core is hard.
The program with the smallest core size (the smallest N) wins. In case of ties the winner is the full program (the (N+8)×(N+8) square) with the fewest distinct characters (not counting newlines).
Please report your N value at the top of your answer.