Created
August 21, 2021 16:01
-
-
Save YonatanKra/e27899e67d44e24961fb68a80bedb070 to your computer and use it in GitHub Desktop.
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
const N = 2; | |
const RANDOM_INITIAL_RANGE = 10; | |
const MATRIX_LENGTH = Math.pow(2, N) + 1; | |
function randomInRange(min, max) { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
} | |
function generateeMatrix() { | |
const matrix = new Array(MATRIX_LENGTH) | |
.fill(0) | |
.map(() => new Array(MATRIX_LENGTH).fill(null)); | |
matrix[0][MATRIX_LENGTH - 1] = randomInRange(0, RANDOM_INITIAL_RANGE); | |
matrix[MATRIX_LENGTH - 1][0] = randomInRange(0, RANDOM_INITIAL_RANGE); | |
matrix[0][0] = randomInRange(0, RANDOM_INITIAL_RANGE); | |
matrix[MATRIX_LENGTH - 1][MATRIX_LENGTH - 1] = randomInRange( | |
0, | |
RANDOM_INITIAL_RANGE | |
); | |
return matrix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment