8
1
The Challenge
Write a program that takes an integer N as input, and outputs the stage of life or death that a tree is currently in. N will always be between 0 and 10.
The Stages of Life and Death
Life: To draw a stage of life, simply draw a base of size N, consisting of
^
characters, then move up and substract 2 from N, if the result is greater than 0, and draw a line of^
characters again, again with the size of the new N. Repeat while N is larger than 0. To finish off, place either a single|
character if the startoff value of N is odd, or two||
characters if it was even.
Example:N = 5
^ ^^^ ^^^^^ |
Note that if N = 0, only the stem will be drawn, without the leaves (
^
) on them.Death: This is roughly the same as Life, except that the base is 10 - N, you use
M
instead of^
and you add 2 to N and redraw the lines with the same procedure as above, but this time you add 2 to N while it is smaller or equal to 10.
Example:N = 3
M MMM MMMMM MMMMMMM |
The Goal
Your program has to run in 2 different languages both have to take a input N. The first language has to output the life stage of a tree according to N, the second language has to output the death stage.
Rules
- This is code-golf, the shortest code in bytes that meets all the requirements wins.
- The code has to run in 2 different languages. Yes, Python 2 and Python 3 are different languages.
- Standard loopholes are forbidden.
- Trailing newlines or spaces are allowed.
Test Cases
Input: N = 1
First language (life):
^
|
Second language (death):
M
MMM
MMMMM
MMMMMMM
MMMMMMMMM
|
Input: N = 10
First language (life):
^^
^^^^
^^^^^^
^^^^^^^^
^^^^^^^^^^
||
Second language (death):
||
Good luck coding!
can there be trailing/leading newlines or trailing spaces? – dzaima – 2017-09-30T15:20:31.357
@dzaima Yes, i'll edit that in. – Ian H. – 2017-09-30T20:48:53.187