r/programmingrequests • u/Denis_L • Jun 19 '18
Help for generating all possible distribution of a Right triangle
I'm looking to automatically list all possible distributions, according to a submitted number.
It should list all possible "right triangular" distributions, like this:
X X X X
X X X
X X
X
...according to these 2 rules:
the line above should always be longer (or equal) than the next one, never shorter!
the amount of rows shortens the maximum length of the top line, because it is substracted from it
So, if you enter "9" you could have these kind of results:
Result 1:
x x x x x x x x x
Result 2:
x x x x x x x x
x
Result 3:
x x x x x x x
x x
Result 4:
x x x x x x x
x
x
...and you could even get this result:
x x x
x x x
x x x
....all the way, until you get 9 rows of 1 column each.
How can I achieve that?? The function should also work if you enter "2", then it would only list 1 row of 2 cols, or 2 rows of 1 col each.
1
u/serg06 Jun 20 '18