JavaScript (ES6), 61 bytes
Takes input in currying syntax (c)(s)
, where s is 1-indexed. Returns a 1-dimensional array.
c=>s=>[...Array(c*c)].map((_,k)=>(k=k%c>k/c?k%c:k/c)<s?-~k:0)
Takes input in currying syntax (c)(s)
, where s is 1-indexed. Returns a 1-dimensional array.
c=>s=>[...Array(c*c)].map((_,k)=>(k=k%c>k/c?k%c:k/c)<s?-~k:0)