Skip to main content
4 of 4
Commonmark migration

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)

Try it online!

Arnauld
  • 197.7k
  • 20
  • 179
  • 650