Now that we know how to properly square and triangle a number, we are going to learn how to parallelogram one. To parallelogram a number, we first arrange it as a parallelogram by stacking it on top of itself a number of times equal to the number of digits it has, and adding spaces to make it a parallelogram. So 123
would form:
123
123
123
Now we take each horizontal and vertical number and add them, 123+123+123+1+12+123+23+3
, which equals 531
, which is the parallelogram of 123
.
Your Task:
Write a program or function that, when given a number as input, returns the parallelogram of the number.
Input:
A non-negative integer, or a non-negative integer represented by a string.
Output:
The parallelogram of the integer.
Test Cases:
1234567 -> 10288049
123 -> 531
101 -> 417
12 -> 39
Scoring:
This is code-golf, lowest score in bytes wins!