Given a natural number n, return two
-element vectors, x and y, containing the coordinates of a triangular arrangement of points, where:
- there are n rows of points
- the kth row contains k points
- all points in the kth row have y = k
- the x coordinates in each row are equally spaced a distance of 1 and centered at 0
The points should be given in order, row 1 to row n, with the x coordinate in each row given in ascending numerical order.
For example:
x = [0 -0.5 0.5 -1 0 1 -1.5 -0.5 0.5 1.5 -2 -1 0 1 2]
y = [1 2 2 3 3 3 4 4 4 4 5 5 5 5 5]
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers103
Suggested Problems
-
Given an unsigned integer x, find the largest y by rearranging the bits in x
2070 Solvers
-
396 Solvers
-
355 Solvers
-
764 Solvers
-
Generate Pascal's Triangle Matrix
155 Solvers
More from this Author12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!