fix(curriculum): typos in curriculum code parts (#51884)

Co-authored-by: Viktor Szépe <viktor@szepe.net>
This commit is contained in:
Krzysztof G
2023-10-10 09:12:37 +02:00
committed by GitHub
parent de5b3e165e
commit 3b25ed538b
12 changed files with 35 additions and 35 deletions
@@ -58,8 +58,8 @@ class PrimeSeive {
// Mark value in seive array
const prime = 2 * i + 3;
// Mark all multiples of this number as false (not prime)
const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSqaredIndex; j < upper; j += prime) {
const primeSquaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSquaredIndex; j < upper; j += prime) {
seive[j] = false;
}
}
@@ -231,13 +231,13 @@ async (getUserInput) => {
};
const url = getUserInput('url') + '/api/issues/fcc-project';
const itemToUpdate = await $.post(url, initialData);
const updateSucccess = await $.ajax({
const updateSuccess = await $.ajax({
url: url,
type: 'PUT',
data: { _id: itemToUpdate._id, issue_text: 'New Issue Text' }
});
assert.isObject(updateSucccess);
assert.deepEqual(updateSucccess, {
assert.isObject(updateSuccess);
assert.deepEqual(updateSuccess, {
result: 'successfully updated',
_id: itemToUpdate._id
});
@@ -82,7 +82,7 @@ const OPERATORS_ = {
"/": (a, b) => a / b,
}
const PRECIDENCE_ = {
const PRECEDENCE_ = {
"+": 1,
"-": 1,
"*": 2,
@@ -114,7 +114,7 @@ function evaluate_(expression) {
case "*":
case "/":
while (stack.length &&
PRECIDENCE_[c] <= PRECIDENCE_[stack[stack.length-1]]) {
PRECEDENCE_[c] <= PRECEDENCE_[stack[stack.length-1]]) {
postfix += stack.pop();
}
stack.push(c);
@@ -175,7 +175,7 @@ function dealFreeCell(seed) {
const rng = FreeCellRNG(seed);
const deck = getDeck();
const deltCards = [[], [], [], [], [], [], []];
const dealtCards = [[], [], [], [], [], [], []];
let currentColumn = 0;
let currentRow = 0;
@@ -195,7 +195,7 @@ function dealFreeCell(seed) {
card = deck.pop();
// Deal this card
deltCards[currentRow].push(card);
dealtCards[currentRow].push(card);
currentColumn += 1;
if (currentColumn === 8) {
currentColumn = 0;
@@ -203,6 +203,6 @@ function dealFreeCell(seed) {
}
}
return deltCards;
return dealtCards;
}
```
@@ -101,7 +101,7 @@ function combinations(possibleNumbers, total) {
function combinations(possibleNumbers, total) {
let firstNumber;
let secondNumber;
let thridNumber;
let thirdNumber;
const allCombinations = [];
for (let i = 0; i < possibleNumbers.length; i += 1) {
@@ -112,10 +112,10 @@ function combinations(possibleNumbers, total) {
secondNumber = possibleNumbers[j];
if (j !== i && firstNumber + secondNumber <= total) {
thridNumber = total - firstNumber - secondNumber;
thirdNumber = total - firstNumber - secondNumber;
if (thridNumber !== firstNumber && thridNumber !== secondNumber && possibleNumbers.includes(thridNumber)) {
allCombinations.push([firstNumber, secondNumber, thridNumber]);
if (thirdNumber !== firstNumber && thirdNumber !== secondNumber && possibleNumbers.includes(thirdNumber)) {
allCombinations.push([firstNumber, secondNumber, thirdNumber]);
}
}
}
@@ -71,8 +71,8 @@ class PrimeSeive {
// Mark value in seive array
const prime = 2 * i + 3;
// Mark all multiples of this number as false (not prime)
const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSqaredIndex; j < upper; j += prime) {
const primeSquaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSquaredIndex; j < upper; j += prime) {
seive[j] = false;
}
}
@@ -73,7 +73,7 @@ substringDivisibility(5);
```js
function substringDivisibility(n) {
function isSubDivisable(digits) {
function isSubDivisible(digits) {
const factors = [2, 3, 5, 7, 11, 13, 17];
for (let i = 1; i < digits.length - 2; i++) {
@@ -108,17 +108,17 @@ function substringDivisibility(n) {
}
const allowedDigits = [...new Array(n + 1).keys()];
const divisablePandigitals = [];
const divisiblePandigitals = [];
heapsPermutations(
allowedDigits.length,
allowedDigits,
isSubDivisable,
divisablePandigitals
isSubDivisible,
divisiblePandigitals
);
let sum = 0;
for (let i = 0; i < divisablePandigitals.length; i++) {
sum += divisablePandigitals[i];
for (let i = 0; i < divisiblePandigitals.length; i++) {
sum += divisiblePandigitals[i];
}
return sum;
@@ -67,8 +67,8 @@ class PrimeSeive {
const prime = 2 * i + 3;
primes.push(prime);
// Mark all multiples of this number as false (not prime)
const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSqaredIndex; j < upper; j += prime) {
const primeSquaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSquaredIndex; j < upper; j += prime) {
seive[j] = false;
}
}
@@ -67,8 +67,8 @@ class PrimeSeive {
// Mark value in seive array
const prime = 2 * i + 3;
// Mark all multiples of this number as false (not prime)
const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSqaredIndex; j < upper; j += prime) {
const primeSquaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSquaredIndex; j < upper; j += prime) {
seive[j] = false;
}
}
@@ -39,10 +39,10 @@ For $1 ≤ k ≤ 200$, find $\sum{m(k)}$.
# --hints--
`efficientExponentation()` should return `1582`.
`efficientExponentiation()` should return `1582`.
```js
assert.strictEqual(efficientExponentation(), 1582);
assert.strictEqual(efficientExponentiation(), 1582);
```
# --seed--
@@ -50,12 +50,12 @@ assert.strictEqual(efficientExponentation(), 1582);
## --seed-contents--
```js
function efficientExponentation() {
function efficientExponentiation() {
return true;
}
efficientExponentation();
efficientExponentiation();
```
# --solutions--
@@ -67,8 +67,8 @@ class PrimeSeive {
// Mark value in seive array
const prime = 2 * i + 3;
// Mark all multiples of this number as false (not prime)
const primeSqaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSqaredIndex; j < upper; j += prime) {
const primeSquaredIndex = 2 * i ** 2 + 6 * i + 3;
for (let j = primeSquaredIndex; j < upper; j += prime) {
seive[j] = false;
}
}
@@ -35,7 +35,7 @@ concealedSquare();
```js
// Check if n**2 matches the pattern
function squareMatchs(n) {
function squareMatches(n) {
// Need BigInt due to size of values
let nSquared = (BigInt(n) * BigInt(n)).toString();
@@ -55,8 +55,8 @@ function concealedSquare() {
for (let x = maxSquareRoot; x >= minSquareRoot; x -= 10) {
// Note: 3*3 = 9 and 7*7 = 49 are only trailing digits
// that can produce 9 as trailing digit in square
if (squareMatchs(x + 3)) return (x + 3)*10;
if (squareMatchs(x + 7)) return (x + 7)*10;
if (squareMatches(x + 3)) return (x + 3)*10;
if (squareMatches(x + 7)) return (x + 7)*10;
}
return -1;
}