Given a list of N
non-negative integers, output those numbers with each left-padded by spaces to a length of N
. (Alternatively, return a character/string list.) You may assume that N
is greater than or equal to the number of digits of the largest number in the list. Trailing spaces are allowed in the output.
You may also take a string containing these numbers, but N
is not the length of the string, but rather the number of elements in the list; also, you may take a list of strings e.g. ["1", "2", "3"]
.
This is a code-golf, so the shortest program in bytes wins.
Test cases
input => 'output'
0 => '0'
1 => '1'
2 3 => ' 2 3'
2 10 => ' 210'
4 5 6 => ' 4 5 6'
17 19 20 => ' 17 19 20'
7 8 9 10 => ' 7 8 9 10'
100 200 300 0 => ' 100 200 300 0'
1000 400 30 7 => '1000 400 30 7'
1 33 333 7777 => ' 1 33 3337777'
0 0 0 0 0 0 => ' 0 0 0 0 0 0'