/\ / \ / \ /\/\ / \ /\ /\/ \ /\ / \/\ /\/\/\ for n=3 pairs of ups and downs I have 5 possible way to draw these mountains.(I should never go below the x
Solution 1:
Your problem is you are using ' '
spaces as litteral space. HTML doenst like literal spaces all that well.. Best to use
as
document.write(o.join('<br>').replace(/,\d?/g, r => '\\/' [r[1]] || ' '));
One other thing, use a fixed-width font and proper line-height
for better results.
JSFiddle Example
Post a Comment for "Printing Mountain Ranges Algorithm"