Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

1 of 2
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

R, 65 bytes

f=function(n)"if"(n,kronecker(matrix(c(0,3:1),2),4*f(n-1),"+"),0)

Try it online!

Recursive function. Takes \$log_2(s)\$ as an input and returns the corresponding \$s\times s\$ matrix as output. 2 bytes shorter than using rbind and cbind:

R, 67 bytes

f=function(n)"if"(n,cbind(rbind(g<-4*f(n-1),g+3),rbind(g+2,g+1)),0)

Try it online!

Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

AltStyle によって変換されたページ (->オリジナル) /