Skip to content

Instantly share code, notes, and snippets.

@birkir
Created December 1, 2014 16:06
Show Gist options
  • Save birkir/83b8149eb1727ecdac39 to your computer and use it in GitHub Desktop.
Save birkir/83b8149eb1727ecdac39 to your computer and use it in GitHub Desktop.
Jóladagatal 1/24 - Christmas Tree
function tree(w) {
return "\n" + Array.apply(null, Array(w)).map(function (_, x) {
return Array.apply(null, Array(w*2)).map(function (_, y) {
if (y === w-x && x === 0) return 'X';
if (y > (w-x) && y < (w+x)) return (Math.random() > 0.7) ? '@' : '.';
return (y === w-x) ? '/' : ((y === w+x) ? '\\' : ' ');
}).join('');
}).join("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment