Skip to main content
added 337 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me to this approach. Test harness taken from pajonk's answer.

In an \$m\times n\$ matrix \$A\$, each element \$A_{ij}\$ is in the \$p^\text{th}\$ J-bracket if and only if \$\min(i,n+1-j)=p\$.

R has some odd built-ins that return the matrix \$R=\text{row}(M)\$ where \$R_{ij}=i\$ and similarly for \$C=\text{col}(M)\$. Reversing the column matrix luckily performs the right operation, and we take the parallel minimum of these matrices to obtain a matrix of J-brackets, which split helpfully breaks into groups of the right order.

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me to this approach. Test harness taken from pajonk's answer.

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me to this approach. Test harness taken from pajonk's answer.

In an \$m\times n\$ matrix \$A\$, each element \$A_{ij}\$ is in the \$p^\text{th}\$ J-bracket if and only if \$\min(i,n+1-j)=p\$.

R has some odd built-ins that return the matrix \$R=\text{row}(M)\$ where \$R_{ij}=i\$ and similarly for \$C=\text{col}(M)\$. Reversing the column matrix luckily performs the right operation, and we take the parallel minimum of these matrices to obtain a matrix of J-brackets, which split helpfully breaks into groups of the right order.

deleted 1 character in body
Source Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me thoto this approach. Test harness taken from pajonk's answer.

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me tho this approach. Test harness taken from pajonk's answer.

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me to this approach. Test harness taken from pajonk's answer.

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 37 bytes

\(m)split(m,pmin(row(m),rev(col(m))))

Attempt This Online!

Working on the related challenge led me tho this approach. Test harness taken from pajonk's answer.