Inspired by Display a chain of little mountains with an odd number on the top of it! by @sygmei.
Why have a chain of mountains when you can have one massive one?
Make a program that takes an input number and prints a mountain with every odd number up to the input number.
(Where "south west" means directly below and to the left
, and "south east" means directly below and to the right
)
Every number will have a /
south west of it, and a \
south east. It starts from 1
at the top, and the next number will go south west of a /
or south east of a \
. The next number will go in the line closest to the top and to the left most possible.
For a multidigit number, just the 1st digit needs to be in the right place with the other digits directly after, and only the first digit should have \
and /
coming out from it.
The mountain up to 1 or 2 is just:
1
/ \
A mountain up to 3 or 4 is just:
1
/ \
3
/ \
For 25 or 26:
1
/ \
3 5
/ \ / \
7 9 11
/ \ / \ / \
13 15 17 19
/ \ / \ / \ / \
21 23 25
/ \ / \ / \
Last two lines where the input is 121:
111 113 115 117 119 121
/ \ / \ / \ / \ / \ / \
And the last two lines where the input is 1019:
993 995 997 999 1001100310051007100910111013101510171019
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
You may assume that the input will be greater than 0 and less than 10001 (exclusive).
Trailing spaces are OK, and extra leading spaces are alright as long as there is the same on all lines.
This is code-golf, so the shortest program in bytes wins.
An ungolfed answer to this can be found online here (In Python on repl.it) if you need more test cases.