Make an upside down triangle of positive integers. Every number in the triangle must be distinct. Each number is the summation of its two parents (similar to how Pascal's triangle is constructed, but upside-down). Construct it in such a way that the bottom number is minimized.
For example, for input
n = 4, here is a possible solution:
4 1 2 7 5 3 9 8 12 20
A reversal of the top numbers, such as
7 2 1 4, would also work.
n = 5, here is a possible solution:
7 2 1 4 6 9 3 5 10 12 8 15 20 23 43
The solution for
n = 2 is rather boring:
1 2 3
The sequence of bottom numbers is described in OEIS A028307.
Given an input integer
n > 0 describing how many elements are in the first row, output the corresponding minimal triangle as explained above. Output can be as ASCII-art of the triangle, a list-of-lists or matrix, to STDOUT as one row per line, etc.
- If applicable, you can assume that the input/output will fit in your language's native Integer type.
- The input and output can be given by any convenient method.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.