Inspired by Bake a slice of Pi
Challenge
Given input 3 <= n <= 100
and 3 <= y <= n
, construct an n x n
matrix of the decimal portion of pi
(14159...
), starting in the top left. Then, take the upper-right triangle of size y x y
and concatenate it together. Output the resulting number.
For example, for input n = 5
, y = 3
, the following matrix is constructed
14159
26535
89793
23846
26433
Then, the upper-right 3 x 3
triangle would be
159
35
3
so 159353
is the output.
Input
Two integers -- n
representing the size of the square matrix of the digits of pi, and y
representing the upper-right triangle -- in any convenient format.
Output
- The resulting sliced and concatenated number, either printed/displayed to the screen, returned as a string, etc.
- Trailing/leading whitespace is optional, so long as there's no whitespace in the output (i.e.,
159 35 3
or the like would be invalid). - Note that since we're explicitly looking for the digits of
pi
, and not an approximation or mathematical calculation, answers should not round the final digit of the matrix.
Rules
- This is code-golf so all the usual rules for golfing apply, and the shortest code (in bytes) wins.
- Either a full program or function are acceptable.
- Standard loopholes are forbidden.
Examples
n y output
-------------
3 3 141923
5 3 159353
6 4 1592589383
6 6 141592535893238643794
20 12 358979323846950288419715820974944628620899211706792306647223172745025559196615