Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sierpenskis Gasket
function sierpinski(n)
{
return (function s(n)
{
return !n ? ['L'] : s(--n).map(function (a)
{
return a + new Array((1 << (n + 1)) + 1).join(' ')
}).concat(s(n).map(function (a)
{
return a + ' ' + a
}));
})(n).join('@').replace(/ *@/g, '\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment