Skip to content

Instantly share code, notes, and snippets.

@OneCent01
Created May 25, 2017 16:51
Show Gist options
  • Save OneCent01/a00309cdee69343545a6ce4fac8365e8 to your computer and use it in GitHub Desktop.
Save OneCent01/a00309cdee69343545a6ce4fac8365e8 to your computer and use it in GitHub Desktop.
Attempt at pascal's triangle
var generate = function(numRows) {
var result = [];
for(var i = 1; i <= numRows; i++) {
var inner = [];
for(var j = 0; j < i; j++) {
inner.push(Math.abs(j + 1));
}
if (j%2 > 0) {
for(var q = i - 1; q >= 1; q--) {
inner.push(Math.abs(q));
}
}
result.push(inner);
} return result;
};
generate(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment