19
Starting with /\
you can create a Sierpinski triangle like pattern by adding a line beneath such that...
- Any loose branch
/
or\
splits again into two branches:/\
. - Any collision of branches
\/
dies with nothing (but spaces) under it.
Repeating these rules yields
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
etc...
Write a program or function that takes in a positive integer N and prints the first N lines of this pattern to stdout, with no more leading or trailing spaces than necessary.
For example, if the input is 1
the output must be
/\
If the input is 2
the output must be
/\
/\/\
If the input is 8
the output must be
/\
/\/\
/\ /\
/\/\/\/\
/\ /\
/\/\ /\/\
/\ /\ /\ /\
/\/\/\/\/\/\/\/\
And so on.
The code with the fewest bytes wins.
1Can you please make it "fewest bytes" to avoid code compression shenanigans? – xnor – 2014-10-04T05:31:00.883
@xnor Changed . – Calvin's Hobbies – 2014-10-04T06:05:05.770
I was literally about to post this. Meanie. :/ – Kaz Wolfe – 2014-10-04T08:34:57.570
Where's the APL answer? – Joe – 2014-10-04T23:13:14.523