Skip to main content
Commonmark migration
Source Link

#MATL, 40 bytes

MATL, 40 bytes

#MATL, 40 bytes

MATL, 40 bytes

deleted 34 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
t % input 2D char array. Duplicate. The original copy will produce % the words left to right when displayed ! % transpose. This will produce the words up to down tP! % duplicate, flip upside down, transpose. This will produce the % words right to left tP! % duplicate, flip upside down, transposeSame. This will produce the % words down to up GXK % push input again. Copy to clipboard K Zy % get size (length-2 vector; [4 5] in the example) q % decrement by 1 (gives [3 4] in the example) XI % copy to clipboard I " % loop: do this twice, consuming the decremented length-2 vector I % push decremented size vector again Z} % split into its two elements (pushes 3 and 4 in the example) w_w % swap, negave, swap (results in -3, 4 in the example) 2$: % binary range: indices of diagonals ([-3 -2 -1 0 1 2 3 4] % in the first iteration in the example, [-4 -3 -2 -1 0 1 2 3] % in the second) " % for each K % push input (first iteration) or its tranposed version (second) @ % push index of diagonal 2$Xd! % extract that diagonal as a row vector ] % end for each K!XKx % update clipboard K with transposed version for next iteration % end loop. Display 
t % input 2D char array. Duplicate. The original copy will produce % the words left to right when displayed ! % transpose. This will produce the words up to down tP! % duplicate, flip upside down, transpose. This will produce the % words right to left tP! % duplicate, flip upside down, transpose. This will produce the % words down to up GXK % push input again. Copy to clipboard K Zy % get size (length-2 vector; [4 5] in the example) q % decrement by 1 (gives [3 4] in the example) XI % copy to clipboard I " % loop: do this twice, consuming the decremented length-2 vector I % push decremented size vector again Z} % split into its two elements (pushes 3 and 4 in the example) w_w % swap, negave, swap (results in -3, 4 in the example) 2$: % binary range: indices of diagonals ([-3 -2 -1 0 1 2 3 4] % in the first iteration in the example, [-4 -3 -2 -1 0 1 2 3] % in the second) " % for each K % push input (first iteration) or its tranposed version (second) @ % push index of diagonal 2$Xd! % extract that diagonal as a row vector ] % end for each K!XKx % update clipboard K with transposed version for next iteration % end loop. Display 
t % input 2D char array. Duplicate. The original copy will produce % the words left to right when displayed ! % transpose. This will produce the words up to down tP! % duplicate, flip upside down, transpose. This will produce the % words right to left tP! % Same. This will produce the words down to up GXK % push input again. Copy to clipboard K Zy % get size (length-2 vector; [4 5] in the example) q % decrement by 1 (gives [3 4] in the example) XI % copy to clipboard I " % loop: do this twice, consuming the decremented length-2 vector I % push decremented size vector again Z} % split into its two elements (pushes 3 and 4 in the example) w_w % swap, negave, swap (results in -3, 4 in the example) 2$: % binary range: indices of diagonals ([-3 -2 -1 0 1 2 3 4] % in the first iteration in the example, [-4 -3 -2 -1 0 1 2 3] % in the second) " % for each K % push input (first iteration) or its tranposed version (second) @ % push index of diagonal 2$Xd! % extract that diagonal as a row vector ] % end for each K!XKx % update clipboard K with transposed version for next iteration % end loop. Display 
added 1549 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL#MATL, 40 bytes

t % input 2D char array. Duplicate. The original copy will produce % the words left to right when displayed ! % transpose. This will produce the words up to down tP! % duplicate, flip upside down, transpose. This will produce the % words right to left tP! % duplicate, flip upside down, transpose. This will produce the % words down to up GXK % push input again. Copy to clipboard K Zy % get size (length-2 vector; [4 5] in the example) q % decrement by 1 (gives [3 4] in the example) XI % copy to clipboard I " % loop: do this twice, consuming the decremented length-2 vector I % push decremented size vector again Z} % split into its two elements (pushes 3 and 4 in the example) w_w % swap, negave, swap (results in -3, 4 in the example) 2$: % binary range: indices of diagonals ([-3 -2 -1 0 1 2 3 4] % in the first iteration in the example, [-4 -3 -2 -1 0 1 2 3] % in the second) " % for each K % push input (first iteration) or its tranposed version (second) @ % push index of diagonal 2$Xd! % extract that diagonal as a row vector ] % end for each K!XKx % update clipboard K with transposed version for next iteration % end loop. Display 

#MATL, 40 bytes

#MATL, 40 bytes

t % input 2D char array. Duplicate. The original copy will produce % the words left to right when displayed ! % transpose. This will produce the words up to down tP! % duplicate, flip upside down, transpose. This will produce the % words right to left tP! % duplicate, flip upside down, transpose. This will produce the % words down to up GXK % push input again. Copy to clipboard K Zy % get size (length-2 vector; [4 5] in the example) q % decrement by 1 (gives [3 4] in the example) XI % copy to clipboard I " % loop: do this twice, consuming the decremented length-2 vector I % push decremented size vector again Z} % split into its two elements (pushes 3 and 4 in the example) w_w % swap, negave, swap (results in -3, 4 in the example) 2$: % binary range: indices of diagonals ([-3 -2 -1 0 1 2 3 4] % in the first iteration in the example, [-4 -3 -2 -1 0 1 2 3] % in the second) " % for each K % push input (first iteration) or its tranposed version (second) @ % push index of diagonal 2$Xd! % extract that diagonal as a row vector ] % end for each K!XKx % update clipboard K with transposed version for next iteration % end loop. Display 
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading