Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix typos #1283

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cache/Memoize.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const memoize = (func, cache = new Map()) => {
/**
* Arguments converted to JSON string for use as a key of Map - it's easy to detect collections like -> Object and Array
* If the args input is -> [new Set([1, 2, 3, 4]), {name: 'myName', age: 23}]
* Then the agrsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string
* Then the argsKey generate to -> '[[1,2,3,4],{"name":"myName","age":23}]' which is JSON mean string
* Now it's ready to be a perfect key for Map
*/
const argsKey = JSON.stringify(args, jsonReplacer)
Expand Down
2 changes: 1 addition & 1 deletion Ciphers/test/AffineCipher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Test Affine Cipher', () => {
expect(() => encrypt('null', 4, 1)).toThrow()
})

it('Test - 3 Pass string value to encrypt and ecrypt function', () => {
it('Test - 3 Pass string value to encrypt and decrypt function', () => {
expect(decrypt(encrypt('HELLO WORLD', 5, 8), 5, 8)).toBe('HELLO WORLD')
expect(decrypt(encrypt('ABC DEF', 3, 5), 3, 5)).toBe('ABC DEF')
expect(decrypt(encrypt('Brown fox jump over the fence', 7, 3), 7, 3)).toBe(
Expand Down
4 changes: 2 additions & 2 deletions Ciphers/test/KeywordShiftedAlphabet.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { encrypt, decrypt } from '../KeywordShiftedAlphabet'

test('Hello world! === dcrypt(encrypt(Hello world!))', () => {
test('Hello world! === decrypt(encrypt(Hello world!))', () => {
const word = 'Hello world!'
const result = decrypt('keyword', encrypt('keyword', word))
expect(result).toMatch(word)
})

test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => {
test('The Algorithms === decrypt(encrypt(The Algorithms))', () => {
const word = 'The Algorithms'
const result = decrypt('keyword', encrypt('keyword', word))
expect(result).toMatch(word)
Expand Down
4 changes: 2 additions & 2 deletions Ciphers/test/VigenereCipher.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { encrypt, decrypt } from '../VigenereCipher'

test('Hello world! === dcrypt(encrypt(Hello world!))', () => {
test('Hello world! === decrypt(encrypt(Hello world!))', () => {
const word = 'Hello world!'
const result = decrypt(encrypt(word, 'code'), 'code')
expect(result).toMatch(word)
})

test('The Algorithms === dcrypt(encrypt(The Algorithms))', () => {
test('The Algorithms === decrypt(encrypt(The Algorithms))', () => {
const word = 'The Algorithms'
const result = decrypt(encrypt(word, 'code'), 'code')
expect(result).toMatch(word)
Expand Down
2 changes: 1 addition & 1 deletion Conversions/BinaryToHex.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const hexLookup = (bin) => {
}
const binaryToHex = (binaryString) => {
/*
Function for convertung Binary to Hex
Function for converting Binary to Hex

1. The conversion will start from Least Significant Digit (LSB) to the Most Significant Bit (MSB).
2. We divide the bits into sections of 4-bits starting from LSB to MSB.
Expand Down
4 changes: 2 additions & 2 deletions Conversions/RailwayTimeConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const RailwayTimeConversion = (timeString) => {
return new TypeError('Argument is not a string.')
}
// split the string by ':' character.
const [hour, minute, scondWithShift] = timeString.split(':')
const [hour, minute, secondWithShift] = timeString.split(':')
// split second and shift value.
const [second, shift] = [scondWithShift.substr(0, 2), scondWithShift.substr(2)]
const [second, shift] = [secondWithShift.substr(0, 2), secondWithShift.substr(2)]
// convert shifted time to not-shift time(Railway time) by using the above explanation.
if (shift === 'PM') {
if (parseInt(hour) === 12) { return `${hour}:${minute}:${second}` } else { return `${parseInt(hour) + 12}:${minute}:${second}` }
Expand Down
10 changes: 5 additions & 5 deletions Conversions/test/TemperatureConversion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ describe('Testing Conversion of Rankine to Kelvin', () => {
expect(test1).toBe(6)
})
})
describe('Testing Conversion of Reamur to Celsius', () => {
it('with Reamur value', () => {
describe('Testing Conversion of Reaumur to Celsius', () => {
it('with Reaumur value', () => {
const test1 = tc.reaumurToCelsius(100)
expect(test1).toBe(125)
})
})
describe('Testing Conversion of Reamur to Fahrenheit', () => {
it('with Reamur value', () => {
describe('Testing Conversion of Reaumur to Fahrenheit', () => {
it('with Reaumur value', () => {
const test1 = tc.reaumurToFahrenheit(100)
expect(test1).toBe(257)
})
})
describe('Testing Conversion of Reamur to Kelvin', () => {
describe('Testing Conversion of Reaumur to Kelvin', () => {
it('with Reamur value', () => {
const test1 = tc.reaumurToKelvin(100)
expect(test1).toBe(398)
Expand Down
2 changes: 1 addition & 1 deletion Data-Structures/Array/LocalMaximomPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Notes:
* - works by using divide and conquer
* - the function gets the array A with n Real numbersand returns the local max point index (if more than one exists return the first one)
* - the function gets the array A with n Real numbers and returns the local max point index (if more than one exists return the first one)
*
* @complexity: O(log(n)) (on average )
* @complexity: O(log(n)) (worst case)
Expand Down
6 changes: 3 additions & 3 deletions Data-Structures/Tree/Trie.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ Trie.prototype.remove = function (word, count) {
if (child.count >= count) child.count -= count
else child.count = 0

// If some occurrences are left we dont delete it or else
// if the object forms some other objects prefix we dont delete it
// If some occurrences are left we don't delete it or else
// if the object forms some other objects prefix we don't delete it
// For checking an empty object
// https://stackoverflow.com/questions/679915/how-do-i-test-for-an-empty-javascript-object
if (child.count <= 0 && (Object.keys(child.children).length && child.children.constructor === Object)) {
Expand All @@ -110,7 +110,7 @@ Trie.prototype.contains = function (word) {
return true
}

Trie.prototype.findOccurences = function (word) {
Trie.prototype.findOccurrences = function (word) {
// find the node with given prefix
const node = this.findPrefix(word)
// No such word exists
Expand Down
14 changes: 7 additions & 7 deletions Dynamic-Programming/KadaneAlgo.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Kadane's algorithm is one of the most efficient ways to
* calculate the maximum contiguous subarray sum for a given array.
* Below is the implementation of kadanes's algorithm along with
* Below is the implementation of Kadane's algorithm along with
* some sample test cases.
* There might be a special case in this problem if al the elements
* of the given array are negative. In such a case, the maximum negative
Expand All @@ -10,14 +10,14 @@
*/

export function kadaneAlgo (array) {
let cummulativeSum = 0
let cumulativeSum = 0
let maxSum = Number.NEGATIVE_INFINITY // maxSum has the least possible value
for (let i = 0; i < array.length; i++) {
cummulativeSum = cummulativeSum + array[i]
if (maxSum < cummulativeSum) {
maxSum = cummulativeSum
} else if (cummulativeSum < 0) {
cummulativeSum = 0
cumulativeSum = cumulativeSum + array[i]
if (maxSum < cumulativeSum) {
maxSum = cumulativeSum
} else if (cumulativeSum < 0) {
cumulativeSum = 0
}
}
return maxSum
Expand Down
2 changes: 1 addition & 1 deletion Dynamic-Programming/UniquePaths2.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const uniquePaths2 = (obstacles) => {
grid[0][j] = 1
}
// Fill the rest of grid by dynamic programming
// using following reccurent formula:
// using following recurrent formula:
// K[i][j] = K[i - 1][j] + K[i][j - 1]
for (let i = 1; i < rows; i++) {
for (let j = 1; j < columns; j++) {
Expand Down
2 changes: 1 addition & 1 deletion Geometry/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This class represents a circle and can calculate it's perimeter and area
* https://en.wikipedia.org/wiki/Circle
* @constructor
* @param {number} radius - The radius of the circule.
* @param {number} radius - The radius of the circle.
*/
export default class Circle {
constructor (radius) {
Expand Down
2 changes: 1 addition & 1 deletion Graphs/BinaryLifting.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Binary Lifting implementation in Javascript
* Binary Lifting is a technique that is used to find the kth ancestor of a node in a rooted tree with N nodes
* The technique requires preprocessing the tree in O(N log N) using dynamic programming
* The techniqe can answer Q queries about kth ancestor of any node in O(Q log N)
* The technique can answer Q queries about kth ancestor of any node in O(Q log N)
* It is faster than the naive algorithm that answers Q queries with complexity O(Q K)
* It can be used to find Lowest Common Ancestor of two nodes in O(log N)
* Tutorial on Binary Lifting: https://codeforces.com/blog/entry/100826
Expand Down
2 changes: 1 addition & 1 deletion Graphs/LCABinaryLifting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Author: Adrito Mukherjee
* Findind Lowest Common Ancestor By Binary Lifting implementation in JavaScript
* Finding Lowest Common Ancestor By Binary Lifting implementation in JavaScript
* The technique requires preprocessing the tree in O(N log N) using dynamic programming)
* It can be used to find Lowest Common Ancestor of two nodes in O(log N)
* Tutorial on Lowest Common Ancestor: https://www.geeksforgeeks.org/lca-in-a-tree-using-binary-lifting-technique
Expand Down
2 changes: 1 addition & 1 deletion Maths/BinomialCoefficient.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/**
* @function findBinomialCoefficient
* @description -> this function returns bonimial coefficient
* @description -> this function returns binomial coefficient
* of two numbers n & k given by n!/((n-k)!k!)
* @param {number} n
* @param {number} k
Expand Down
2 changes: 1 addition & 1 deletion Maths/CheckKishnamurthyNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CheckKishnamurthyNumber = (number) => {
sumOfAllDigitFactorial += factorial(lastDigit)
newNumber = Math.floor(newNumber / 10)
}
// if the sumOftheFactorial is equal to the given number it means the number is a Krishnamurthy number.
// if the sumOfAllDigitFactorial is equal to the given number it means the number is a Krishnamurthy number.
return sumOfAllDigitFactorial === number
}

Expand Down
2 changes: 1 addition & 1 deletion Maths/ExtendedEuclideanGCD.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Problem statement and explanation: https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm
*
* This algorithm plays an important role for modular arithmetic, and by extension for cyptography algorithms
* This algorithm plays an important role for modular arithmetic, and by extension for cryptography algorithms
*
* Basic explanation:
* The Extended Euclidean algorithm is a modification of the standard Euclidean GCD algorithm.
Expand Down
2 changes: 1 addition & 1 deletion Maths/FermatPrimalityTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* 1 / 2^50 = 8.8 * 10^-16 (a pretty small number)
*
* For comparison, the probability of a cosmic ray causing an error to your
* infalible program is around 1.4 * 10^-15. An order of magnitude below!
* infallible program is around 1.4 * 10^-15. An order of magnitude below!
*
* But because nothing is perfect, there's a major flaw to this algorithm, and
* the cause are the so called Carmichael Numbers. These are composite numbers n
Expand Down
2 changes: 1 addition & 1 deletion Maths/test/MeanAbsoluteDeviation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('tests for mean absolute deviation', () => {
expect(() => meanAbsoluteDeviation('fgh')).toThrow()
})

it('should return the mean absolute devition of an array of numbers', () => {
it('should return the mean absolute deviation of an array of numbers', () => {
const meanAbDev = meanAbsoluteDeviation([2, 34, 5, 0, -2])
expect(meanAbDev).toBe(10.479999999999999)
})
Expand Down
12 changes: 6 additions & 6 deletions Project-Euler/Problem003.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// https://projecteuler.net/problem=3

export const largestPrime = (num = 600851475143) => {
let newnumm = num
let newnum = num
let largestFact = 0
let counter = 2
while (counter * counter <= newnumm) {
if (newnumm % counter === 0) {
newnumm = newnumm / counter
while (counter * counter <= newnum) {
if (newnum % counter === 0) {
newnum = newnum / counter
} else {
counter++
}
}
if (newnumm > largestFact) {
largestFact = newnumm
if (newnum > largestFact) {
largestFact = newnum
}
return largestFact
}
6 changes: 3 additions & 3 deletions Project-Euler/Problem008.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

const largestAdjacentNumber = (grid, consecutive) => {
grid = grid.split('\n').join('')
const splitedGrid = grid.split('\n')
const splitGrid = grid.split('\n')
let largestProd = 0

for (const row in splitedGrid) {
const currentRow = splitedGrid[row].split('').map(x => Number(x))
for (const row in splitGrid) {
const currentRow = splitGrid[row].split('').map(x => Number(x))

for (let i = 0; i < currentRow.length - consecutive; i++) {
const combine = currentRow.slice(i, i + consecutive)
Expand Down
2 changes: 1 addition & 1 deletion Project-Euler/Problem023.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

/**
* collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the llst of sums, adds them and returns their sum.
* collect the abundant numbers, generate and store their sums with each other, and check for numbers not in the list of sums, adds them and returns their sum.
* @param {number} [n = 28123]
* @returns {number}
*/
Expand Down
2 changes: 1 addition & 1 deletion Project-Euler/Problem028.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function problem28 (dim) {
* Third corner: i^2 - 2 * (i - 1)
* Fourth corner: i^2 - 3 * (i - 1)
*
* Doing the sum of each corner and simplifing, we found that the result for each dimension is:
* Doing the sum of each corner and simplifying, we found that the result for each dimension is:
* sumDim = 4 * i^2 + 6 * (1 - i)
*
* In this case I skip the 1x1 dim matrix because is trivial, that's why I start in a 3x3 matrix
Expand Down
4 changes: 2 additions & 2 deletions Sorts/IntroSort.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @function Intosort (As implemented in STD C++ Lib)
* @function Introsort (As implemented in STD C++ Lib)
* The function performs introsort which is used in
* C++ Standard LIbrary, the implementation is inspired from]
* library routine itself.
Expand Down Expand Up @@ -88,7 +88,7 @@ function introsort (array, compare) {
const THRESHOLD = 16
/**
* @constant TUNEMAXDEPTH
* Constant usec to increase or decrease value
* Constant used to increase or decrease value
* of maxDepth
*/
const TUNEMAXDEPTH = 1
Expand Down