In math a magic square is an N×N grid of numbers from 1 to N2 such that every row, column, and diagonal sums to the same total. For example here's a 3×3 magic square:
In this challenge we'll extend the idea to magic code squares where, instead of numbers, each grid cell is any non-newline character. They can be be repeated and in any order.
And instead of sums, each row, column, and diagonal is viewed as an N-character single-line program whose output is a distinct number from 0 to 2N+1 (inclusive).
For example, if you had a 4×4 magic code square that looked like
ABCD EFGH IJKL MNOP
it would need to output the numbers 0 through 9, perhaps like:
ABCD-9 EFGH-2 IJKL-6 MNOP-5 /||||\ 3 4180 7
That is, the ten embedded 4-character single-line programs that form the rows, columns, and diagonals of the grid each need to output a unique number from 0 through 9. In this case:
ABCD -> 9 EFGH -> 2 IJKL -> 6 MNOP -> 5 AFKP -> 7 DHLP -> 0 CGKO -> 8 BFJN -> 1 AEIM -> 4 DGJM -> 3
(Note that the diagonals are read from top to bottom. This is required.)
As another example, this 3×3 code square
d*P 0## ! d
would need to output 0 through 7 when its rows, column, and diagonals are run to make it magical, perhaps like:
d*P-1 0##-0 ! d-6 /|||\ 5 432 7
The goal of this challenge is not necessarily to make the smallest or the biggest magic code square. In some programming languages very small magic code squares might be easy to make and in other languages very large ones might be.
The challenge here is to create what you think is the best, most elegant, or most impressive magic code square or related set of magic code squares. Hence this is a popularity-contest, the answer with the highest number of votes wins.
Your submission must include at least one valid magic code square, and may include many related ones if you have found them, or even an infinite neighborhood of them.
Please list the N (or range of N's) you found at the top of your answer.
For submitting multiple magic code squares in the same language but with very different implementations use multiple answers.
Of course you are encouraged to share your process of searching for magic code squares and explain why yours is interesting! (Info about any Parker magic code squares might be funny.)