Skip to main content
added 271 characters in body
Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

R, 84 8181 67 bytes

Or R>=4.1, 7460 bytes by replacing the word function with a \.

Edit: -14 bytes thanks to @Giuseppe inspired by @Bubbler's Jelly answer.

function(n){m=t(n^21)
while(T<n){T=nrow(m)
m=rbind(n^2-T:1-F:n,t(T=nrow(m))+t(m[T:1,]))
F=F+T}
m}

Try it online!Try it online!

Uses the common "rotate and add a row on top" approach.

See also @Giuseppe's direct construction of the matrix.

R, 84 81 bytes

Or R>=4.1, 74 bytes by replacing the word function with a \.

function(n){m=t(n^2)
while(T<n){T=nrow(m)
m=rbind(n^2-T:1-F,t(m[T:1,]))
F=F+T}
m}

Try it online!

Uses the common "rotate and add a row on top" approach.

R, 84 81 67 bytes

Or R>=4.1, 60 bytes by replacing the word function with a \.

Edit: -14 bytes thanks to @Giuseppe inspired by @Bubbler's Jelly answer.

function(n){m=t(1)
while(T<n)m=rbind(1:n,(T=nrow(m))+t(m[T:1,]))
m}

Try it online!

Uses the common "rotate and add a row on top" approach.

See also @Giuseppe's direct construction of the matrix.

deleted 82 characters in body
Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

R, 8484 81 bytes

Or R>=4.1, 7774 bytes by replacing the word function with a \.

function(n){m=t(s<-n^2)
while(F<s-1T<n){a=nrowT=nrow(m)
m=rbind(sn^2-aT:1-F,t(m[am[T:1,]))
F=F+aF=F+T}
m}

Try it online!Try it online!

Uses the common "rotate and add a row on top" approach.

Probably missed some trivial golf, but I'm looking at this for too long already...

R, 84 bytes

Or R>=4.1, 77 bytes by replacing the word function with a \.

function(n){m=t(s<-n^2)
while(F<s-1){a=nrow(m)
m=rbind(s-a:1-F,t(m[a:1,]))
F=F+a}
m}

Try it online!

Uses the common "rotate and add a row on top" approach.

Probably missed some trivial golf, but I'm looking at this for too long already...

R, 84 81 bytes

Or R>=4.1, 74 bytes by replacing the word function with a \.

function(n){m=t(n^2)
while(T<n){T=nrow(m)
m=rbind(n^2-T:1-F,t(m[T:1,]))
F=F+T}
m}

Try it online!

Uses the common "rotate and add a row on top" approach.

Source Link
pajonk
  • 18.3k
  • 3
  • 26
  • 74

R, 84 bytes

Or R>=4.1, 77 bytes by replacing the word function with a \.

function(n){m=t(s<-n^2)
while(F<s-1){a=nrow(m)
m=rbind(s-a:1-F,t(m[a:1,]))
F=F+a}
m}

Try it online!

Uses the common "rotate and add a row on top" approach.

Probably missed some trivial golf, but I'm looking at this for too long already...