Created
January 16, 2015 23:32
-
-
Save abhiaiyer91/d946e6a8ff962ea571db to your computer and use it in GitHub Desktop.
Sierpenskis Gasket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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