-
-
Save t0mdicks0n/bd924210a031a2470e3618d871dc3b4b to your computer and use it in GitHub Desktop.
awdawd
This file contains hidden or 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
| dwadwa |
This file contains hidden or 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
| var pascal = [ | |
| [1], | |
| [1,1], | |
| [1,2,1], | |
| [1,3,3,1], | |
| [1,4,6,4,1] | |
| ]; | |
| function generetaPascal(numRows) { | |
| var triangle; | |
| function pyramid(targetSum) { | |
| if (triangle.length === numRows) { | |
| return triangle; | |
| } | |
| // get new sum by checking the length of the last sum in the triangle and multiply it by two | |
| // wanted length = triangle.length - 2 | |
| // rest = wantedSum - 2 | |
| // | |
| if (numRows.length === 0) { | |
| triangle.push([1]); | |
| } else if (numRows.length === 1) { | |
| triangle.push([1]); | |
| } else { | |
| var newSum = pascal.length * 2; | |
| var wantedLen = triangle.length - 2; | |
| var specialChar = pascal.length; | |
| var rest = newSum - 2 - (specialChar * 2); | |
| if (newSum === specialChar + 2) { | |
| triangle.push(1, specialChar, 1); | |
| return; | |
| } else { | |
| } | |
| triangle.push([1, specialChar, Number([].join()), specialChar, 1]); | |
| } | |
| restNumArr = []; | |
| } | |
| pyramid(triangle.length * 2); | |
| pyramid(1); | |
| return triangle; | |
| } | |
| 1, pascal.length | |
| 2, pascal.length * 2 | |
| 4, pascal.length * 2 | |
| 8, pascal.length * 2 | |
| 16, pascal.length * 2 |
This file contains hidden or 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
| adwwad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment