2017-10: Squaring Off
Write a function that will reshape a given array into the smallest square matrix that will contain all the elements of the argument, padding with additional elements if necessary. The pad element should be 0
if the array is numeric and space ' '
if the array is character.
Examples:
(your_function) 1 2 3 4
1 2
3 4
(your_function) 1 2 3 4 5
1 2 3
4 5 0
0 0 0
(your_function) 'Dyalog APL' ⍝ should work with any data
Dyal
og A
PL
' '=your_function 'Dyalog APL' ⍝ show where the spaces are
0 0 0 0
0 0 1 0
0 0 1 1
1 1 1 1
(your_function) 100 ⍝ should return a 1×1 matrix
100
(your_function) ⍬ ⍝ should return a 0×0 matrix
⍴your_function ⍬ ⍝ should return a 0×0 matrix
0 0
your_function ←
Solutions

