-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
913a134
commit 5f77747
Showing
4 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const convertToRomanNumeral = num => { | ||
let roman = { | ||
M: 1000, | ||
CM: 900, | ||
D: 500, | ||
CD: 400, | ||
C: 100, | ||
XC: 90, | ||
L: 50, | ||
XL: 40, | ||
X: 10, | ||
IX: 9, | ||
V: 5, | ||
IV: 4, | ||
I: 1 | ||
}; | ||
let str = ""; | ||
|
||
for (let i of Object.keys(roman)) { | ||
let q = Math.floor(num / roman[i]); | ||
num -= q * roman[i]; | ||
console.log(num); | ||
str += i.repeat(q); | ||
} | ||
|
||
return str; | ||
}; | ||
const result = convertToRomanNumeral(8); | ||
console.log(result); |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const matrix1 = [[0, 1], [2, 3], [3, 3], [3, 4]]; | ||
const matrix2 = [[0, 4], [2, 3], [3, 3], [3, 4]]; | ||
|
||
// O(n^2) | ||
// const spareMatrixMult = (mtrx1, mtrx2) => { | ||
// let product = []; | ||
// mtrx1.forEach(cell1 => { | ||
// mtrx2.forEach(cell2 => { | ||
// if (cell1[0] === cell2[0] && cell1[1] === cell2[1]) { | ||
// console.log("hit"); | ||
// product.push(cell1); | ||
// } | ||
// }); | ||
// }); | ||
// return product; | ||
// }; | ||
|
||
const spareMatrixMult = (mtrx1, mtrx2) => { | ||
let product = []; | ||
return product; | ||
}; | ||
|
||
const result = spareMatrixMult(matrix1, matrix2); | ||
console.log(result); |