16
2
Given n=m^2
, return a list of integers that do not border the m x m
grid of integers from 1 to n
.
Examples
n=1 (m=1)
Grid:
[1]
Return:
[]
n=4 (m=2)
Grid:
[1,2]
[3,4]
Return:
[]
n=9 (m=3)
Grid:
[1,2,3]
[4,5,6]
[7,8,9]
Return:
[5]
n=16 (m=4)
Grid:
[ 1, 2, 3, 4]
[ 5, 6, 7, 8]
[ 9,10,11,12]
[13,14,15,16]
Return:
[6,7,10,11]
For higher values of m
, this answer does a great visualization.
Rules:
- You may take in either
m
orn
(wheren = m*m
).- If taking in
n
you are allowed to have undefined behavior where there exists nom
forn
(E.G. 15). n > 0
,m > 0
: Both must be integer values.
- If taking in
- The output may be as a 1D/2D array, matrix or whitespace delimited
- The output must be in order from least to greatest.
- If outputting as a matrix this means it must be as it would be in the grid.
- This is code-golf, lowest byte-count wins.
Complete fault on my end, I read it incorrectly. – DevelopingDeveloper – 2018-02-02T21:46:20.930
3@DevelopingDeveloper hey man, if I had a nickle for every time I did that I'd be able to buy a beer or two. – Magic Octopus Urn – 2018-02-02T21:51:01.563
If outputting as a 2D array, can a single empty array be included in the result? – Shaggy – 2018-02-03T09:41:23.970