#!/usr/bin/ruby

# 90-degree version of Sierpinski's triangle
# https://rosettacode.org/wiki/Sierpinski_triangle

func sierpinski_triangle_90(n) {
    var triangle = ['*'];
    { |i|
        var sp = (' ' * 2**i);
        triangle = (triangle.map {|x| x + sp*2} +
                    triangle.map {|x| x + ' ' + x});
    } * n;
    triangle.join("\n");
}

say sierpinski_triangle_90(4);
