mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2026-03-13 15:21:15 +08:00
merge: Fix spellings (#821)
* chore: remove codespell from ci * feat: add codespell workflow * fix: codespell workflow * fix: ignore spellings in directory * chore: fix spellings ./Dynamic-Programming/KadaneAlgo.js:2: contiguos ==> contiguous ./Dynamic-Programming/KadaneAlgo.js:14: posible ==> possible * chore: fix spelling ./Dynamic-Programming/SieveOfEratosthenes.js:4: upto ==> up to * chore: fix spellings ./Dynamic-Programming/MaxNonAdjacentSum.js:22: Exmaple ==> Example * chore: fix spelling ./Project-Euler/test/Problem010.test.js:4: upto ==> up to ./Project-Euler/test/Problem010.test.js:8: upto ==> up to ./Project-Euler/test/Problem010.test.js:12: upto ==> up to * chore: fix spelling ./String/AlphaNumericPalindrome.js:10: recieves ==> receives ./String/AlphaNumericPalindrome.js:10: sting ==> string ./String/AlphaNumericPalindrome.js:46: varaible ==> variable * chore: fix spelling ./String/DiceCoefficient.js:3: stings ==> strings * chore: fix spelling ./String/test/DiceCoefficient.test.js:9: atleast ==> at least * chore: fix spelling ./String/test/MaxWord.test.js:8: ba ==> be * chore: ignore `PermutateString.test.js` * chore: fix spelling ./String/test/CheckVowels.test.js:62: occurances ==> occurrences * chore: ignore `SubsequenceRecursive.js` * chore: fix spelling ./Conversions/TemperatureConversion.js:2: arguement ==> argument * chore: fix spelling ./Conversions/RailwayTimeConversion.js:7: Formate ==> Format ./Conversions/RailwayTimeConversion.js:8: Formate ==> Format * chore: remove Linear Algebra The deleted directory hosted a package which are not accepted by this repository. * Auto-update DIRECTORY.md * chore: fix spelling * chore: fix spellings * merge: Created composite Simpson's integration method. Tests included. (#819) * Created composite Simpson's integration method.Tests included * Minor corrections * Auto-update DIRECTORY.md * Styled with standard.js * chore: remove blank line * chore: remove blank line Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Rak Laptudirm <raklaptudirm@gmail.com> * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: remove codespell from ci * feat: add codespell workflow * fix: codespell workflow * fix: ignore spellings in directory * chore: fix spellings ./Dynamic-Programming/KadaneAlgo.js:2: contiguos ==> contiguous ./Dynamic-Programming/KadaneAlgo.js:14: posible ==> possible * chore: fix spelling ./Dynamic-Programming/SieveOfEratosthenes.js:4: upto ==> up to * chore: fix spellings ./Dynamic-Programming/MaxNonAdjacentSum.js:22: Exmaple ==> Example * chore: fix spelling ./Project-Euler/test/Problem010.test.js:4: upto ==> up to ./Project-Euler/test/Problem010.test.js:8: upto ==> up to ./Project-Euler/test/Problem010.test.js:12: upto ==> up to * chore: fix spelling ./String/AlphaNumericPalindrome.js:10: recieves ==> receives ./String/AlphaNumericPalindrome.js:10: sting ==> string ./String/AlphaNumericPalindrome.js:46: varaible ==> variable * chore: fix spelling ./String/DiceCoefficient.js:3: stings ==> strings * chore: fix spelling ./String/test/DiceCoefficient.test.js:9: atleast ==> at least * chore: fix spelling ./String/test/MaxWord.test.js:8: ba ==> be * chore: ignore `PermutateString.test.js` * chore: fix spelling ./String/test/CheckVowels.test.js:62: occurances ==> occurrences * chore: ignore `SubsequenceRecursive.js` * chore: fix spelling ./Conversions/TemperatureConversion.js:2: arguement ==> argument * chore: fix spelling ./Conversions/RailwayTimeConversion.js:7: Formate ==> Format ./Conversions/RailwayTimeConversion.js:8: Formate ==> Format * chore: remove Linear Algebra The deleted directory hosted a package which are not accepted by this repository. * Auto-update DIRECTORY.md * chore: fix spelling * chore: fix spellings * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: fix spelling * chore: no need to check filenames Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: ggkogkou <76820848+ggkogkou@users.noreply.github.com> Co-authored-by: ggkogkou <ggkogkou@ggkogkou.gr>
This commit is contained in:
@@ -12,13 +12,13 @@
|
||||
// = exponent(x*x, floor(n/2)) ; if n is odd
|
||||
// = x*exponent(x*x, floor(n/2)) ; if n is even
|
||||
const exponent = (x, n) => {
|
||||
let ans = 1
|
||||
let answer = 1
|
||||
while (n > 0) {
|
||||
if (n % 2 !== 0) ans *= x
|
||||
if (n % 2 !== 0) answer *= x
|
||||
n = Math.floor(n / 2)
|
||||
if (n > 0) x *= x
|
||||
}
|
||||
return ans
|
||||
return answer
|
||||
}
|
||||
|
||||
export { exponent }
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
*/
|
||||
|
||||
export const decimalIsolate = (number) => {
|
||||
const ans = parseFloat((number + '').replace(/^[-\d]+./, '.'))
|
||||
return isNaN(ans) === true ? 0 : ans
|
||||
const answer = parseFloat((number + '').replace(/^[-\d]+./, '.'))
|
||||
return isNaN(answer) === true ? 0 : answer
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
Problem Statment and Explanation :
|
||||
Problem Statement and Explanation :
|
||||
Triangular => https://en.wikipedia.org/wiki/Triangular_number
|
||||
Tetrahedral => https://en.wikipedia.org/wiki/Tetrahedral_number
|
||||
Pentatope => https://en.wikipedia.org/wiki/Pentatope_number
|
||||
|
||||
@@ -22,27 +22,27 @@ const Identity = (n) => {
|
||||
return res
|
||||
}
|
||||
|
||||
const MatMult = (matA, matB) => {
|
||||
// Input: matA: 2D Array of Numbers of size n x n
|
||||
// matB: 2D Array of Numbers of size n x n
|
||||
// Output: matA x matB: 2D Array of Numbers of size n x n
|
||||
const MatMult = (matrixA, matrixB) => {
|
||||
// Input: matrixA: 2D Array of Numbers of size n x n
|
||||
// matrixB: 2D Array of Numbers of size n x n
|
||||
// Output: matrixA x matrixB: 2D Array of Numbers of size n x n
|
||||
// Complexity: O(n^3)
|
||||
const n = matA.length
|
||||
const matC = []
|
||||
const n = matrixA.length
|
||||
const matrixC = []
|
||||
for (let i = 0; i < n; i++) {
|
||||
matC[i] = []
|
||||
matrixC[i] = []
|
||||
for (let j = 0; j < n; j++) {
|
||||
matC[i][j] = 0
|
||||
matrixC[i][j] = 0
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < n; i++) {
|
||||
for (let j = 0; j < n; j++) {
|
||||
for (let k = 0; k < n; k++) {
|
||||
matC[i][j] += matA[i][k] * matB[k][j]
|
||||
matrixC[i][j] += matrixA[i][k] * matrixB[k][j]
|
||||
}
|
||||
}
|
||||
}
|
||||
return matC
|
||||
return matrixC
|
||||
}
|
||||
|
||||
export const MatrixExponentiationRecursive = (mat, m) => {
|
||||
|
||||
@@ -17,7 +17,7 @@ const matrixCheck = (matrix) => {
|
||||
}
|
||||
}
|
||||
|
||||
// tests to see if the matrices have a like side, i.e. the row length on the first matrix matches the column length on the second matrix, or vise versa.
|
||||
// tests to see if the matrices have a like side, i.e. the row length on the first matrix matches the column length on the second matrix, or vice versa.
|
||||
const twoMatricesCheck = (first, second) => {
|
||||
const [firstRowLength, secondRowLength, firstColLength, secondColLength] = [first.length, second.length, matrixCheck(first), matrixCheck(second)]
|
||||
if (firstRowLength !== secondColLength || secondRowLength !== firstColLength) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const sieveOfEratosthenes = (n) => {
|
||||
/*
|
||||
* Calculates prime numbers till a number n
|
||||
* :param n: Number upto which to calculate primes
|
||||
* :param n: Number up to which to calculate primes
|
||||
* :return: A boolean list containing only primes
|
||||
*/
|
||||
const primes = new Array(n + 1)
|
||||
|
||||
@@ -59,7 +59,7 @@ function integralEvaluation (N, a, b, func) {
|
||||
|
||||
result *= temp
|
||||
|
||||
if (Number.isNaN(result)) { throw Error('Result is NaN. The input interval doesnt belong to the functions domain') }
|
||||
if (Number.isNaN(result)) { throw Error("Result is NaN. The input interval doesn't belong to the functions domain") }
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user