diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/697a49e9860d24853adef67c.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/697a49e9860d24853adef67c.md index 587b1af984a..d4689253f59 100644 --- a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/697a49e9860d24853adef67c.md +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/697a49e9860d24853adef67c.md @@ -12,7 +12,7 @@ Given an array representing the weights of the athletes on a bobsled team and a - The length of the array determines the team size: 1, 2 or 4 person teams. - All given weight values are in kilograms (kg). -The bobsled (sled by iteself) must have a minimum weight of: +The bobsled (sled by itself) must have a minimum weight of: - 162 kg for a 1-person team - 170 kg for a 2-person team diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa0.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa0.md new file mode 100644 index 00000000000..0974adf41b9 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa0.md @@ -0,0 +1,129 @@ +--- +id: 698a1a73ade5ac0e19180fa0 +title: "Challenge 197: Blood Type Compatibility" +challengeType: 28 +dashedName: challenge-197 +--- + +# --description-- + +Given a donor blood type and a recipient blood type, determine whether the donor can give blood to the recipient. + +Each blood type consists of: + +- A letter: `"A"`, `"B"`, `"AB"`, or `"O"` +- And an Rh factor: `"+"` or `"-"` + +Blood types will be one of the valid letters followed by an Rh factor. For example, `"AB+"` and `"O-"` are valid blood types. + +Letter Rules: + +- `"O"` can donate to other letter type. +- `"A"` can donate to `"A"` and `"AB"`. +- `"B"` can donate to `"B"` and `"AB"`. +- `"AB"` can donate only to `"AB"`. + +Rh Rules: + +- Negative (`"-"`) can donate to both `"-"` and `"+"`. +- Positive (`"+"`) can donate only to `"+"`. + +Both letter and Rh rule must pass for a donor to be able to donate to the recipient. + +# --hints-- + +`canDonate("B+", "B+")` should return `true`. + +```js +assert.isTrue(canDonate("B+", "B+")); +``` + +`canDonate("O-", "AB-")` should return `true`. + +```js +assert.isTrue(canDonate("O-", "AB-")); +``` + +`canDonate("O+", "A-")` should return `false`. + +```js +assert.isFalse(canDonate("O+", "A-")); +``` + +`canDonate("A+", "AB+")` should return `true`. + +```js +assert.isTrue(canDonate("A+", "AB+")); +``` + +`canDonate("A-", "B-")` should return `false`. + +```js +assert.isFalse(canDonate("A-", "B-")); +``` + +`canDonate("B-", "AB+")` should return `true`. + +```js +assert.isTrue(canDonate("B-", "AB+")); +``` + +`canDonate("B-", "A+")` should return `false`. + +```js +assert.isFalse(canDonate("B-", "A+")); +``` + +`canDonate("O-", "O+")` should return `true`. + +```js +assert.isTrue(canDonate("O-", "O+")); +``` + +`canDonate("O+", "O-")` should return `false`. + +```js +assert.isFalse(canDonate("O+", "O-")); +``` + +`canDonate("AB+", "AB-")` should return `false`. + +```js +assert.isFalse(canDonate("AB+", "AB-")); +``` + +# --seed-- + +## --seed-contents-- + +```js +function canDonate(donor, recipient) { + + return donor; +} +``` + +# --solutions-- + +```js +function canDonate(donor, recipient) { + const donorType = donor.slice(0, -1); + const donorRh = donor.slice(-1); + + const recipientType = recipient.slice(0, -1); + const recipientRh = recipient.slice(-1); + + const aboCompatibility = { + "O": ["A", "B", "AB", "O"], + "A": ["A", "AB"], + "B": ["B", "AB"], + "AB": ["AB"] + }; + + const aboMatch = aboCompatibility[donorType].includes(recipientType); + const rhMatch = + donorRh === "-" || (donorRh === "+" && recipientRh === "+"); + + return aboMatch && rhMatch; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa1.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa1.md new file mode 100644 index 00000000000..8c288dc5ad3 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa1.md @@ -0,0 +1,78 @@ +--- +id: 698a1a73ade5ac0e19180fa1 +title: "Challenge 198: Business Day Count" +challengeType: 28 +dashedName: challenge-198 +--- + +# --description-- + +Given a start date and an end date, return the number of business days between the two. + +- Given dates are in the format `"YYYY-MM-DD"`. +- Weekdays are business days (Monday through Friday). +- Weekends are not business days (Saturday and Sunday). +- Include both the start and end dates when counting. + +# --hints-- + +`countBusinessDays("2026-02-24", "2026-02-26")` should return `3`. + +```js +assert.equal(countBusinessDays("2026-02-24", "2026-02-26"), 3); +``` + +`countBusinessDays("2026-02-24", "2026-02-28")` should return `4`. + +```js +assert.equal(countBusinessDays("2026-02-24", "2026-02-28"), 4); +``` + +`countBusinessDays("2026-02-21", "2026-03-01")` should return `5`. + +```js +assert.equal(countBusinessDays("2026-02-21", "2026-03-01"), 5); +``` + +`countBusinessDays("2026-03-08", "2026-03-17")` should return `7`. + +```js +assert.equal(countBusinessDays("2026-03-08", "2026-03-17"), 7); +``` + +`countBusinessDays("2026-02-24", "2027-02-24")` should return `262`. + +```js +assert.equal(countBusinessDays("2026-02-24", "2027-02-24"), 262); +``` + +# --seed-- + +## --seed-contents-- + +```js +function countBusinessDays(start, end) { + + return start; +} +``` + +# --solutions-- + +```js +function countBusinessDays(start, end) { + const startDate = new Date(start + "T00:00:00Z"); + const endDate = new Date(end + "T00:00:00Z"); + + let count = 0; + let current = new Date(startDate); + + while (current <= endDate) { + const day = current.getUTCDay(); + if (day !== 0 && day !== 6) count++; + current.setUTCDate(current.getUTCDate() + 1); + } + + return count; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa2.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa2.md new file mode 100644 index 00000000000..98d47ccd3a1 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa2.md @@ -0,0 +1,71 @@ +--- +id: 698a1a73ade5ac0e19180fa2 +title: "Challenge 199: Sequential Difference" +challengeType: 28 +dashedName: challenge-199 +--- + +# --description-- + +Given an array of numbers, return a new array containing the value needed to get from each number to the next number. + +- For the last number, use `0` since there is no next number. + +For example, given `[1, 2, 4, 7]`, return `[1, 2, 3, 0]`. + +# --hints-- + +`findDifferences([1, 2, 4, 7])` should return `[1, 2, 3, 0]`. + +```js +assert.deepEqual(findDifferences([1, 2, 4, 7]), [1, 2, 3, 0]); +``` + +`findDifferences([10, 15, 19, 22, 24, 25])` should return `[5, 4, 3, 2, 1, 0]`. + +```js +assert.deepEqual(findDifferences([10, 15, 19, 22, 24, 25]), [5, 4, 3, 2, 1, 0]); +``` + +`findDifferences([25, 20, 16, 13, 11, 10])` should return `[-5, -4, -3, -2, -1, 0]`. + +```js +assert.deepEqual(findDifferences([25, 20, 16, 13, 11, 10]), [-5, -4, -3, -2, -1, 0]); +``` + +`findDifferences([0, 1, 2, 2, 3, 3, 4, 5])` should return `[ 1, 1, 0, 1, 0, 1, 1, 0 ]`. + +```js +assert.deepEqual(findDifferences([0, 1, 2, 2, 3, 3, 4, 5]), [ 1, 1, 0, 1, 0, 1, 1, 0 ]); +``` + +`findDifferences([1, 2, 5, 12, 34, -15, -1, 41, 113, -222, -99, -40, 10, -18, -6, -2, -1])` should return `[1, 3, 7, 22, -49, 14, 42, 72, -335, 123, 59, 50, -28, 12, 4, 1, 0]`. + +```js +assert.deepEqual(findDifferences([1, 2, 5, 12, 34, -15, -1, 41, 113, -222, -99, -40, 10, -18, -6, -2, -1]), [1, 3, 7, 22, -49, 14, 42, 72, -335, 123, 59, 50, -28, 12, 4, 1, 0]); +``` + +# --seed-- + +## --seed-contents-- + +```js +function findDifferences(arr) { + + return arr; +} +``` + +# --solutions-- + +```js +function findDifferences(arr) { + const result = []; + + for (let i = 0; i < arr.length; i++) { + result.push(arr[i + 1] - arr[i] || 0); + } + + return result; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa3.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa3.md new file mode 100644 index 00000000000..70e0620afef --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa3.md @@ -0,0 +1,81 @@ +--- +id: 698a1a73ade5ac0e19180fa3 +title: "Challenge 200: Letter and Number Count" +challengeType: 28 +dashedName: challenge-200 +--- + +# --description-- + +Given a string, return a message with the count of how many letters and numbers it contains. + +- Letters are `A-Z` and `a-z`. +- Numbers are `0-9`. +- Ignore all other characters. + +Return `"The string has X letters and Y numbers."`, where `"X"` is the count of letters and `"Y"` is the count of numbers. If either count is 1, use the singular form for that item. E.g: `"1 letter"` instead of `"1 letters"` and `"1 number"` instead of `"1 numbers"`. + +# --hints-- + +`countLettersAndNumbers("helloworld123")` should return `"The string has 10 letters and 3 numbers."`. + +```js +assert.equal(countLettersAndNumbers("helloworld123"), "The string has 10 letters and 3 numbers."); +``` + +`countLettersAndNumbers("Catch 22")` should return `"The string has 5 letters and 2 numbers."`. + +```js +assert.equal(countLettersAndNumbers("Catch 22"), "The string has 5 letters and 2 numbers."); +``` + +`countLettersAndNumbers("A1!")` should return `"The string has 1 letter and 1 number."`. + +```js +assert.equal(countLettersAndNumbers("A1!"), "The string has 1 letter and 1 number."); +``` + +`countLettersAndNumbers("12345")` should return `"The string has 0 letters and 5 numbers."`. + +```js +assert.equal(countLettersAndNumbers("12345"), "The string has 0 letters and 5 numbers."); +``` + +`countLettersAndNumbers("password")` should return `"The string has 8 letters and 0 numbers."`. + +```js +assert.equal(countLettersAndNumbers("password"), "The string has 8 letters and 0 numbers."); +``` + +# --seed-- + +## --seed-contents-- + +```js +function countLettersAndNumbers(str) { + + return str; +} +``` + +# --solutions-- + +```js +function countLettersAndNumbers(str) { + let letterCount = 0; + let numberCount = 0; + + for (let char of str) { + if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) { + letterCount++; + } else if (char >= '0' && char <= '9') { + numberCount++; + } + } + + const letterWord = letterCount === 1 ? "letter" : "letters"; + const numberWord = numberCount === 1 ? "number" : "numbers"; + + return `The string has ${letterCount} ${letterWord} and ${numberCount} ${numberWord}.`; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa4.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa4.md new file mode 100644 index 00000000000..42ef6792b8b --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa4.md @@ -0,0 +1,106 @@ +--- +id: 698a1a73ade5ac0e19180fa4 +title: "Challenge 201: Matrix Shift" +challengeType: 28 +dashedName: challenge-201 +--- + +# --description-- + +Given a matrix (array of arrays) of numbers and an integer, shift all values in the matrix by the given amount. + +- A positive shift moves values to the right. +- A negative shift moves values to the left. + +Values should wrap: + +- Treat the matrix as one continuous sequence of values. +- When a value moves past the end of a row, it continues at the beginning of the next row. +- When a value moves past the last position in the matrix, it wraps to the first position. +- The same applies in reverse when shifting left. + +For example, given: + +```js +[ + [1, 2, 3], + [4, 5, 6] +] +``` + +with a shift of `1`, move all the numbers to the right one: + +```js +[ + [6, 1, 2], + [3, 4, 5] +] +``` + +# --hints-- + +`shiftMatrix([[1, 2, 3], [4, 5, 6]], 1)` should return `[[6, 1, 2], [3, 4, 5]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3], [4, 5, 6]], 1), [[6, 1, 2], [3, 4, 5]]); +``` + +`shiftMatrix([[1, 2, 3], [4, 5, 6]], -1)` should return `[[2, 3, 4], [5, 6, 1]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3], [4, 5, 6]], -1), [[2, 3, 4], [5, 6, 1]]); +``` + +`shiftMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 5)` should return `[[5, 6, 7], [8, 9, 1], [2, 3, 4]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 5), [[5, 6, 7], [8, 9, 1], [2, 3, 4]]); +``` + +`shiftMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], -6)` should return `[[7, 8, 9], [1, 2, 3], [4, 5, 6]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], -6), [[7, 8, 9], [1, 2, 3], [4, 5, 6]]); +``` + +`shiftMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 7)` should return `[[10, 11, 12, 13], [14, 15, 16, 1], [2, 3, 4, 5], [6, 7, 8, 9]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 7), [[10, 11, 12, 13], [14, 15, 16, 1], [2, 3, 4, 5], [6, 7, 8, 9]]); +``` + +`shiftMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], -54)` should return `[[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 1, 2], [3, 4, 5, 6]]`. + +```js +assert.deepEqual(shiftMatrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], -54), [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 1, 2], [3, 4, 5, 6]]); +``` + +# --seed-- + +## --seed-contents-- + +```js +function shiftMatrix(matrix, shift) { + + return matrix; +} +``` + +# --solutions-- + +```js +function shiftMatrix(matrix, shift) { + const rows = matrix.length; + const cols = matrix[0].length; + const flat = matrix.flat(); + const n = flat.length; + const s = ((shift % n) + n) % n; + const shifted = flat.slice(-s).concat(flat.slice(0, n - s)); + const result = []; + for (let i = 0; i < rows; i++) { + result.push(shifted.slice(i * cols, (i + 1) * cols)); + } + + return result; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa5.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa5.md new file mode 100644 index 00000000000..4aa0a08862c --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa5.md @@ -0,0 +1,76 @@ +--- +id: 698a1a73ade5ac0e19180fa5 +title: "Challenge 202: Add Punctuation" +challengeType: 28 +dashedName: challenge-202 +--- + +# --description-- + +Given a string of sentences with missing periods, add a period (`"."`) in the following places: + +- Before each space that comes immediately before an uppercase letter +- And at the end of the string + +Return the resulting string. + +# --hints-- + +`addPunctuation("Hello world")` should return `"Hello world."` + +```js +assert.equal(addPunctuation("Hello world"), "Hello world."); +``` + +`addPunctuation("Hello world It's nice today")` should return `"Hello world. It's nice today."` + +```js +assert.equal(addPunctuation("Hello world It's nice today"), "Hello world. It's nice today."); +``` + +`addPunctuation("JavaScript is great Sometimes")` should return `"JavaScript is great. Sometimes."` + +```js +assert.equal(addPunctuation("JavaScript is great Sometimes"), "JavaScript is great. Sometimes."); +``` + +`addPunctuation("A b c D e F g h I J k L m n o P Q r S t U v w X Y Z")` should return `"A b c. D e. F g h. I. J k. L m n o. P. Q r. S t. U v w. X. Y. Z."` + +```js +assert.equal(addPunctuation("A b c D e F g h I J k L m n o P Q r S t U v w X Y Z"), "A b c. D e. F g h. I. J k. L m n o. P. Q r. S t. U v w. X. Y. Z."); +``` + +`addPunctuation("Wait.. For it")` should return `"Wait... For it."` + +```js +assert.equal(addPunctuation("Wait.. For it"), "Wait... For it."); +``` + +# --seed-- + +## --seed-contents-- + +```js +function addPunctuation(sentences) { + + return sentences; +} +``` + +# --solutions-- + +```js +function addPunctuation(sentences) { + let result = ""; + + for (let i = 0; i < sentences.length; i++) { + if (sentences[i] === " " && i + 1 < sentences.length && /[A-Z]/.test(sentences[i + 1])) { + result += "."; + } + result += sentences[i]; + } + result += "."; + + return result; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa6.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa6.md new file mode 100644 index 00000000000..8b591f3188b --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa6.md @@ -0,0 +1,66 @@ +--- +id: 698a1a73ade5ac0e19180fa6 +title: "Challenge 203: Flattened" +challengeType: 28 +dashedName: challenge-203 +--- + +# --description-- + +Given an array, determine if it is flat. + +- An array is flat if none of its elements are arrays. + +# --hints-- + +`isFlat([1, 2, 3, 4])` should return `true`. + +```js +assert.isTrue(isFlat([1, 2, 3, 4])); +``` + +`isFlat([1, [2, 3], 4])` should return `false`. + +```js +assert.isFalse(isFlat([1, [2, 3], 4])); +``` + +`isFlat([1, 0, false, true, "a", "b"])` should return `true`. + +```js +assert.isTrue(isFlat([1, 0, false, true, "a", "b"])); +``` + +`isFlat(["a", [0], "b", true])` should return `false`. + +```js +assert.isFalse(isFlat(["a", [0], "b", true])); +``` + +`isFlat([1, [2, [3, [4, [5]]]], 6])` should return `false`. + +```js +assert.isFalse(isFlat([1, [2, [3, [4, [5]]]], 6])); +``` + +# --seed-- + +## --seed-contents-- + +```js +function isFlat(arr) { + + return arr; +} +``` + +# --solutions-- + +```js +function isFlat(arr) { + for (let el of arr) { + if (Array.isArray(el)) return false; + } + return true; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa7.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa7.md new file mode 100644 index 00000000000..599d03329f1 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa7.md @@ -0,0 +1,73 @@ +--- +id: 698a1a73ade5ac0e19180fa7 +title: "Challenge 204: Sum the Letters" +challengeType: 28 +dashedName: challenge-204 +--- + +# --description-- + +Given a string, return the sum of its letters. + +- Letters are A-Z in uppercase or lowercase +- Letter values are: `"A"` = 1, `"B"` = 2, ..., `"Z"` = 26 +- Uppercase and lowercase letters have the same value. +- Ignore all non-letter characters. + +# --hints-- + +`sumLetters("Hello")` should return `52`. + +```js +assert.equal(sumLetters("Hello"), 52); +``` + +`sumLetters("freeCodeCamp")` should return `94`. + +```js +assert.equal(sumLetters("freeCodeCamp"), 94); +``` + +`sumLetters("The quick brown fox jumps over the lazy dog.")` should return `473`. + +```js +assert.equal(sumLetters("The quick brown fox jumps over the lazy dog."), 473); +``` + +`sumLetters("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ex nisl, pretium eu varius blandit, facilisis quis eros. Vestibulum ante ipsum primis in faucibus orci.")` should return `1681`. + +```js +assert.equal(sumLetters("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ex nisl, pretium eu varius blandit, facilisis quis eros. Vestibulum ante ipsum primis in faucibus orci."), 1681); +``` + +`sumLetters("")` should return `0`. + +```js +assert.equal(sumLetters(""), 0); +``` + +# --seed-- + +## --seed-contents-- + +```js +function sumLetters(str) { + + return str; +} +``` + +# --solutions-- + +```js +function sumLetters(str) { + let total = 0; + for (let char of str) { + let upper = char.toUpperCase(); + if (upper >= "A" && upper <= "Z") { + total += upper.charCodeAt(0) - "A".charCodeAt(0) + 1; + } + } + return total; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa8.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa8.md new file mode 100644 index 00000000000..ea1f19a9719 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa8.md @@ -0,0 +1,81 @@ +--- +id: 698a1a73ade5ac0e19180fa8 +title: "Challenge 205: Perfect Cube Count" +challengeType: 28 +dashedName: challenge-205 +--- + +# --description-- + +Given two integers, determine how many perfect cubes exist in the range between and including the two numbers. + +- The lower number is not garanteed to be the first argument. +- A number is a perfect cube if there exists an integer (`n`) where `n * n * n = number`. For example, 27 is a perfect cube because `3 * 3 * 3 = 27`. + +# --hints-- + +`countPerfectCubes(3, 30)` should return `2`. + +```js +assert.equal(countPerfectCubes(3, 30), 2); +``` + +`countPerfectCubes(1, 30)` should return `3`. + +```js +assert.equal(countPerfectCubes(1, 30), 3); +``` + +`countPerfectCubes(30, 0)` should return `4`. + +```js +assert.equal(countPerfectCubes(30, 0), 4); +``` + +`countPerfectCubes(-64, 64)` should return `9`. + +```js +assert.equal(countPerfectCubes(-64, 64), 9); +``` + +`countPerfectCubes(9214, -8127)` should return `41`. + +```js +assert.equal(countPerfectCubes(9214, -8127), 41); +``` + +# --seed-- + +## --seed-contents-- + +```js +function countPerfectCubes(a, b) { + + return a; +} +``` + +# --solutions-- + +```js +function countPerfectCubes(a, b) { + const start = Math.min(a, b); + const end = Math.max(a, b); + + let count = 0; + let n = 0; + + while (n ** 3 <= end) { + if (n ** 3 >= start) count++; + n++; + } + + n = -1; + while (n ** 3 >= start) { + if (n ** 3 <= end) count++; + n--; + } + + return count; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa9.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa9.md new file mode 100644 index 00000000000..a1a2cad3dd0 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a73ade5ac0e19180fa9.md @@ -0,0 +1,92 @@ +--- +id: 698a1a73ade5ac0e19180fa9 +title: "Challenge 206: Playing Card Values" +challengeType: 28 +dashedName: challenge-206 +--- + +# --description-- + +Given an array of playing cards, return a new array with the numeric value of each card. + +Card Values: + +- An Ace (`"A"`) has a value of 1. +- Numbered cards (`"2"` - `"10"`) have their face value: 2 - 10, respectively. +- Face cards: Jack (`"J"`), Queen (`"Q"`), and King (`"K"`) are each worth 10. + +Suits: + +- Each card has a suit: Spades (`"S"`), Clubs (`"C"`), Diamonds (`"D"`), or Hearts (`"H"`). + +Card Format: + +- Each card is represented as a string: `"valueSuit"`. For Example: `"AS"` is the Ace of Spades, `"10H"` is the Ten of Hearts, and `"QC"` is the Queen of Clubs. + +# --hints-- + +`cardValues(["3H", "4D", "5S"])` should return `[3, 4, 5]`. + +```js +assert.deepEqual(cardValues(["3H", "4D", "5S"]), [3, 4, 5]); +``` + +`cardValues(["AS", "10S", "10H", "6D", "7D"])` should return `[1, 10, 10, 6, 7]`. + +```js +assert.deepEqual(cardValues(["AS", "10S", "10H", "6D", "7D"]), [1, 10, 10, 6, 7]); +``` + +`cardValues(["8D", "QS", "2H", "JC", "9C"])` should return `[8, 10, 2, 10, 9]`. + +```js +assert.deepEqual(cardValues(["8D", "QS", "2H", "JC", "9C"]), [8, 10, 2, 10, 9]); +``` + +`cardValues(["AS", "KS"])` should return `[1, 10]`. + +```js +assert.deepEqual(cardValues(["AS", "KS"]), [1, 10]); +``` + +`cardValues(["10H", "JH", "QH", "KH", "AH"])` should return `[10, 10, 10, 10, 1]`. + +```js +assert.deepEqual(cardValues(["10H", "JH", "QH", "KH", "AH"]), [10, 10, 10, 10, 1]); +``` + +# --seed-- + +## --seed-contents-- + +```js +function cardValues(cards) { + + return cards; +} +``` + +# --solutions-- + +```js +function cardValues(cards) { + const values = []; + + for (let card of cards) { + let valueStr = card.slice(0, card.length - 1); + + let value; + if (valueStr === "A") { + value = 1; + } else if (["J", "Q", "K"].includes(valueStr)) { + value = 10; + } else { + value = parseInt(valueStr, 10); + } + + values.push(value); + } + + return values; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645e.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645e.md new file mode 100644 index 00000000000..e675a7499b5 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645e.md @@ -0,0 +1,89 @@ +--- +id: 698a1a863194f1f4e63f645e +title: "Challenge 207: Smallest Gap" +challengeType: 28 +dashedName: challenge-207 +--- + +# --description-- + +Given a string, return the substring between the two identical characters that have the smallest number of characters between them (smallest gap). + +- There will always be at least one pair of matching characters. +- The returned substring should exclude the matching characters. +- If two or more gaps are the same length, return the characters from the first one. + +For example, given `"ABCDAC"`, return `"DA"`. + +- Only `"A"` and `"C"` repeat in the string. +- The number of characters between the two `"A"` characters is 3, and between the `"C"` characters is 2. +- So return the string between the two `"C"` characters. + +# --hints-- + +`smallestGap("ABCDAC")` should return `"DA"`. + +```js +assert.equal(smallestGap("ABCDAC"), "DA"); +``` + +`smallestGap("racecar")` should return `"e"`. + +```js +assert.equal(smallestGap("racecar"), "e"); +``` + +`smallestGap("A{5e^SD*F4i!o#q6e&rkf(po8|we9+kr-2!3}=4")` should return `"#q6e&rkf(p"`. + +```js +assert.equal(smallestGap("A{5e^SD*F4i!o#q6e&rkf(po8|we9+kr-2!3}=4"), "#q6e&rkf(p"); +``` + +`smallestGap("Hello World")` should return `""`. + +```js +assert.equal(smallestGap("Hello World"), ""); +``` + +`smallestGap("The quick brown fox jumps over the lazy dog.")` should return `"fox"`. + +```js +assert.equal(smallestGap("The quick brown fox jumps over the lazy dog."), "fox"); +``` + +# --seed-- + +## --seed-contents-- + +```js +function smallestGap(str) { + + return str; +} +``` + +# --solutions-- + +```js +function smallestGap(str) { + let minGap = Infinity; + let result = ""; + + for (let i = 0; i < str.length; i++) { + for (let j = i + 1; j < str.length; j++) { + if (str[i] === str[j]) { + const gap = j - i - 1; + + if (gap < minGap) { + minGap = gap; + result = str.slice(i + 1, j); + } + + break; + } + } + } + + return result; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645f.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645f.md new file mode 100644 index 00000000000..fafee2ad4b0 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f645f.md @@ -0,0 +1,138 @@ +--- +id: 698a1a863194f1f4e63f645f +title: "Challenge 208: Trail Traversal" +challengeType: 28 +dashedName: challenge-208 +--- + +# --description-- + +Given an array of strings representing your trail map, return a string of the moves needed to get to your goal. + +The given strings will contain the values: + +- `"C"`: Your current location +- `"G"`: Your goal +- `"T"`: Traversable parts of the trail +- `"-"`: Untraversable parts of the map + +Return a string with the moves needed to follow the trail from your location to your goal where: + +- `"R"` is a move right +- `"D"` is a move down +- `"L"` is a move left +- `"U"` is a move up + +- There will always be a single continuous trail, without any branching, from your current location to your goal. +- Each trail location will have a maximum of two traversable locations touching it. + +For example, given: + +```js +[ + "-CT--", + "--T--", + "--TT-", + "---T-", + "---G-" +] +``` + +Return `"RDDRDD"`. + +# --hints-- + +`navigateTrail(["-CT--", "--T--", "--TT-", "---T-", "---G-"])` should return `"RDDRDD"`. + +```js +assert.equal(navigateTrail(["-CT--", "--T--", "--TT-", "---T-", "---G-"]), "RDDRDD"); +``` + +`navigateTrail(["-----", "--TTG", "--T--", "--T--", "CTT--"])` should return `"RRUUURR"`. + +```js +assert.equal(navigateTrail(["-----", "--TTG", "--T--", "--T--", "CTT--"]), "RRUUURR"); +``` + +`navigateTrail(["-C----", "TT----", "T-----", "TTTTT-", "----G-"])` should return `"DLDDRRRRD"`. + +```js +assert.equal(navigateTrail(["-C----", "TT----", "T-----", "TTTTT-", "----G-"]), "DLDDRRRRD"); +``` + +`navigateTrail(["--------", "-CTTT---", "----T---", "---GT---", "--------"])` should return `"RRRDDL"`. + +```js +assert.equal(navigateTrail(["--------", "-CTTT---", "----T---", "---GT---", "--------"]), "RRRDDL"); +``` + +`navigateTrail(["TTTTTTT-", "T-----T-", "T-----T-", "TTTT--TG", "---C----"])` should return `"ULLLUUURRRRRRDDDR"`. + +```js +assert.equal(navigateTrail(["TTTTTTT-", "T-----T-", "T-----T-", "TTTT--TG", "---C----"]), "ULLLUUURRRRRRDDDR"); +``` + +# --seed-- + +## --seed-contents-- + +```js +function navigateTrail(map) { + + return map; +} +``` + +# --solutions-- + +```js +function navigateTrail(map) { + const rows = map.length; + const cols = map[0].length; + + const directions = [ + [0, 1, "R"], + [1, 0, "D"], + [0, -1, "L"], + [-1, 0, "U"], + ]; + + let row, col; + for (let r = 0; r < rows; r++) { + for (let c = 0; c < cols; c++) { + if (map[r][c] === "C") { + row = r; + col = c; + } + } + } + + let result = ""; + let prev = null; + + while (map[row][col] !== "G") { + for (let [dr, dc, move] of directions) { + const newRow = row + dr; + const newCol = col + dc; + + if ( + newRow >= 0 && + newRow < rows && + newCol >= 0 && + newCol < cols && + (map[newRow][newCol] === "T" || + map[newRow][newCol] === "G") && + (!prev || newRow !== prev[0] || newCol !== prev[1]) + ) { + result += move; + prev = [row, col]; + row = newRow; + col = newCol; + break; + } + } + } + + return result; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f6460.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f6460.md new file mode 100644 index 00000000000..189ed134ce8 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/698a1a863194f1f4e63f6460.md @@ -0,0 +1,82 @@ +--- +id: 698a1a863194f1f4e63f6460 +title: "Challenge 209: Element Size" +challengeType: 28 +dashedName: challenge-209 +--- + +# --description-- + +Given a window size, the width of an element in viewport width `"vw"` units, and the height of an element in viewport height `"vh"` units, determine the size of the element in pixels. + +- The given window size and returned element size are strings in the format `"width x height"`, `"1200 x 800"` for example. + +- `"vw"` units are the percent of window width. `"50vw"` for example, is 50% of the width of the window. +- `"vh"` units are the percent of window height. `"50vh"` for example, is 50% of the height of the window. + +# --hints-- + +`getElementSize("1200 x 800", "50vw", "50vh")` should return `"600 x 400"`. + +```js +assert.equal(getElementSize("1200 x 800", "50vw", "50vh"), "600 x 400"); +``` + +`getElementSize("320 x 480", "25vw", "50vh")` should return `"80 x 240"`. + +```js +assert.equal(getElementSize("320 x 480", "25vw", "50vh"), "80 x 240"); +``` + +`getElementSize("1000 x 500", "7vw", "3vh")` should return `"70 x 15"`. + +```js +assert.equal(getElementSize("1000 x 500", "7vw", "3vh"), "70 x 15"); +``` + +`getElementSize("1920 x 1080", "95vw", "100vh")` should return `"1824 x 1080"`. + +```js +assert.equal(getElementSize("1920 x 1080", "95vw", "100vh"), "1824 x 1080"); +``` + +`getElementSize("1200 x 800", "0vw", "0vh")` should return `"0 x 0"`. + +```js +assert.equal(getElementSize("1200 x 800", "0vw", "0vh"), "0 x 0"); +``` + +`getElementSize("1440 x 900", "100vw", "114vh")` should return `"1440 x 1026"`. + +```js +assert.equal(getElementSize("1440 x 900", "100vw", "114vh"), "1440 x 1026"); +``` + +# --seed-- + +## --seed-contents-- + +```js +function getElementSize(windowSize, elementVw, elementVh) { + + return windowSize; +} +``` + +# --solutions-- + +```js +function getElementSize(windowSize, elementVw, elementVh) { + const [windowWidth, windowHeight] = windowSize + .split(" x ") + .map(Number); + + const vw = Number(elementVw.replace("vw", "")); + const vh = Number(elementVh.replace("vh", "")); + + const widthPx = (vw / 100) * windowWidth; + const heightPx = (vh / 100) * windowHeight; + + return `${widthPx} x ${heightPx}`; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f50f.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f50f.md new file mode 100644 index 00000000000..dacefa8dcf0 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f50f.md @@ -0,0 +1,112 @@ +--- +id: 6994cff2290543b3aec9f50f +title: "Challenge 210: HSL Validator" +challengeType: 28 +dashedName: challenge-210 +--- + +# --description-- + +Given a string, determine whether it is a valid CSS `hsl()` color value. + +- A valid HSL value must be in the format `"hsl(h, s%, l%)"`, where: + - `h` (hue) must be a number between 0 and 360 (inclusive). + - `s` (saturation) must be a percentage between 0% and 100%. + - `l` (lightness) must be a percentage between 0% and 100%. + +- Spaces are only allowed: + - After the opening parenthesis + - Before and/or after the commas + - Before and/or after closing parenthesis + +- Optionally, the value can end with a semi-colon (`";"`). + +For example, `"hsl(240, 50%, 50%)"` is a valid HSL value. + +# --hints-- + +`isValidHSL("hsl(240, 50%, 50%)")` should return `true`. + +```js +assert.isTrue(isValidHSL("hsl(240, 50%, 50%)")); +``` + +`isValidHSL("hsl( 200 , 50% , 75% )")` should return `true`. + +```js +assert.isTrue(isValidHSL("hsl( 200 , 50% , 75% )")); +``` + +`isValidHSL("hsl(99,60%,80%);")` should return `true`. + +```js +assert.isTrue(isValidHSL("hsl(99,60%,80%);")); +``` + +`isValidHSL("hsl(0, 0%, 0%) ;")` should return `true`. + +```js +assert.isTrue(isValidHSL("hsl(0, 0%, 0%) ;")); +``` + +`isValidHSL("hsl( 10 , 20% , 30% ) ;")` should return `true`. + +```js +assert.isTrue(isValidHSL("hsl( 10 , 20% , 30% ) ;")); +``` + +`isValidHSL("hsl(361, 50%, 80%)")` should return `false`. + +```js +assert.isFalse(isValidHSL("hsl(361, 50%, 80%)")); +``` + +`isValidHSL("hsl(300, 101%, 70%)")` should return `false`. + +```js +assert.isFalse(isValidHSL("hsl(300, 101%, 70%)")); +``` + +`isValidHSL("hsl(200, 55%, 75)")` should return `false`. + +```js +assert.isFalse(isValidHSL("hsl(200, 55%, 75)")); +``` + +`isValidHSL("hsl (80, 20%, 10%)")` should return `false`. + +```js +assert.isFalse(isValidHSL("hsl (80, 20%, 10%)")); +``` + +# --seed-- + +## --seed-contents-- + +```js +function isValidHSL(hsl) { + + return hsl; +} +``` + +# --solutions-- + +```js +function isValidHSL(hsl) { + const regex = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)\s*;?$/; + + const match = hsl.match(regex); + if (!match) return false; + + const hue = Number(match[1]); + const sat = Number(match[2]); + const light = Number(match[3]); + + if (hue < 0 || hue > 360) return false; + if (sat < 0 || sat > 100) return false; + if (light < 0 || light > 100) return false; + + return true; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f510.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f510.md new file mode 100644 index 00000000000..2eb16d90f9a --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f510.md @@ -0,0 +1,62 @@ +--- +id: 6994cff2290543b3aec9f510 +title: "Challenge 211: Array Sum" +challengeType: 28 +dashedName: challenge-211 +--- + +# --description-- + +Given an array of numbers, return the sum of all the numbers. + +# --hints-- + +`sumArray([1, 2, 3, 4, 5])` should return `15`. + +```js +assert.equal(sumArray([1, 2, 3, 4, 5]), 15); +``` + +`sumArray([42])` should return `42`. + +```js +assert.equal(sumArray([42]), 42); +``` + +`sumArray([5, -2, 7, -3])` should return `7`. + +```js +assert.equal(sumArray([5, -2, 7, -3]), 7); +``` + +`sumArray([203, 145, -129, 6293, 523, -919, 845, 2434])` should return `9395`. + +```js +assert.equal(sumArray([203, 145, -129, 6293, 523, -919, 845, 2434]), 9395); +``` + +`sumArray([0, 0])` should return `0`. + +```js +assert.equal(sumArray([0, 0]), 0); +``` + +# --seed-- + +## --seed-contents-- + +```js +function sumArray(numbers) { + + return numbers; +} +``` + +# --solutions-- + +```js +function sumArray(numbers) { + + return numbers.reduce((a, c) => c + a, 0); +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f511.md b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f511.md new file mode 100644 index 00000000000..783dd89a0d1 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6994cff2290543b3aec9f511.md @@ -0,0 +1,59 @@ +--- +id: 6994cff2290543b3aec9f511 +title: "Challenge 212: Array Insertion" +challengeType: 28 +dashedName: challenge-212 +--- + +# --description-- + +Given an array, a value to insert into the array, and an index to insert the value at, return a new array with the value inserted at the specified index. + +# --hints-- + +`insertIntoArray([2, 4, 8, 10], 6, 2)` should return `[2, 4, 6, 8, 10]`. + +```js +assert.deepEqual(insertIntoArray([2, 4, 8, 10], 6, 2), [2, 4, 6, 8, 10]); +``` + +`insertIntoArray(["the", "quick", "fox"], "brown", 2)` should return `["the", "quick", "brown", "fox"]`. + +```js +assert.deepEqual(insertIntoArray(["the", "quick", "fox"], "brown", 2), ["the", "quick", "brown", "fox"]); +``` + +`insertIntoArray([], 0, 0)` should return `[0]`. + +```js +assert.deepEqual(insertIntoArray([], 0, 0), [0]); +``` + +`insertIntoArray([0, 1, 1, 2, 3, 8, 13], 5, 5)` should return `[0, 1, 1, 2, 3, 5, 8, 13]`. + +```js +assert.deepEqual(insertIntoArray([0, 1, 1, 2, 3, 8, 13], 5, 5), [0, 1, 1, 2, 3, 5, 8, 13]); +``` + +# --seed-- + +## --seed-contents-- + +```js +function insertIntoArray(arr, value, index) { + + return arr; +} +``` + +# --solutions-- + +```js +function insertIntoArray(arr, value, index) { + return [ + ...arr.slice(0, index), + value, + ...arr.slice(index) + ]; +} +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e9860d24853adef67c.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e9860d24853adef67c.md index f0afae4d5d8..74d541a78ca 100644 --- a/curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e9860d24853adef67c.md +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/697a49e9860d24853adef67c.md @@ -12,7 +12,7 @@ Given an array representing the weights of the athletes on a bobsled team and a - The length of the array determines the team size: 1, 2 or 4 person teams. - All given weight values are in kilograms (kg). -The bobsled (sled by iteself) must have a minimum weight of: +The bobsled (sled by itself) must have a minimum weight of: - 162 kg for a 1-person team - 170 kg for a 2-person team diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa0.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa0.md new file mode 100644 index 00000000000..97f67d4db6c --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa0.md @@ -0,0 +1,159 @@ +--- +id: 698a1a73ade5ac0e19180fa0 +title: "Challenge 197: Blood Type Compatibility" +challengeType: 29 +dashedName: challenge-197 +--- + +# --description-- + +Given a donor blood type and a recipient blood type, determine whether the donor can give blood to the recipient. + +Each blood type consists of: + +- A letter: `"A"`, `"B"`, `"AB"`, or `"O"` +- And an Rh factor: `"+"` or `"-"` + +Blood types will be one of the valid letters followed by an Rh factor. For example, `"AB+"` and `"O-"` are valid blood types. + +Letter Rules: + +- `"O"` can donate to other letter type. +- `"A"` can donate to `"A"` and `"AB"`. +- `"B"` can donate to `"B"` and `"AB"`. +- `"AB"` can donate only to `"AB"`. + +Rh Rules: + +- Negative (`"-"`) can donate to both `"-"` and `"+"`. +- Positive (`"+"`) can donate only to `"+"`. + +Both letter and Rh rule must pass for a donor to be able to donate to the recipient. + +# --hints-- + +`can_donate("B+", "B+")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("B+", "B+"), True)`) +}}) +``` + +`can_donate("O-", "AB-")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("O-", "AB-"), True)`) +}}) +``` + +`can_donate("O+", "A-")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("O+", "A-"), False)`) +}}) +``` + +`can_donate("A+", "AB+")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("A+", "AB+"), True)`) +}}) +``` + +`can_donate("A-", "B-")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("A-", "B-"), False)`) +}}) +``` + +`can_donate("B-", "AB+")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("B-", "AB+"), True)`) +}}) +``` + +`can_donate("B-", "A+")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("B-", "A+"), False)`) +}}) +``` + +`can_donate("O-", "O+")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("O-", "O+"), True)`) +}}) +``` + +`can_donate("O+", "O-")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("O+", "O-"), False)`) +}}) +``` + +`can_donate("AB+", "AB-")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(can_donate("AB+", "AB-"), False)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def can_donate(donor, recipient): + + return donor +``` + +# --solutions-- + +```py +def can_donate(donor, recipient): + donor_type = donor[:-1] + donor_rh = donor[-1] + + recipient_type = recipient[:-1] + recipient_rh = recipient[-1] + + abo_compatibility = { + "O": ["A", "B", "AB", "O"], + "A": ["A", "AB"], + "B": ["B", "AB"], + "AB": ["AB"] + } + + abo_match = recipient_type in abo_compatibility[donor_type] + rh_match = ( + donor_rh == "-" or + (donor_rh == "+" and recipient_rh == "+") + ) + + return abo_match and rh_match +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa1.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa1.md new file mode 100644 index 00000000000..6bf03efd527 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa1.md @@ -0,0 +1,92 @@ +--- +id: 698a1a73ade5ac0e19180fa1 +title: "Challenge 198: Business Day Count" +challengeType: 29 +dashedName: challenge-198 +--- + +# --description-- + +Given a start date and an end date, return the number of business days between the two. + +- Given dates are in the format `"YYYY-MM-DD"`. +- Weekdays are business days (Monday through Friday). +- Weekends are not business days (Saturday and Sunday). +- Include both the start and end dates when counting. + +# --hints-- + +`count_business_days("2026-02-24", "2026-02-26")` should return `3`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_business_days("2026-02-24", "2026-02-26"), 3)`) +}}) +``` + +`count_business_days("2026-02-24", "2026-02-28")` should return `4`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_business_days("2026-02-24", "2026-02-28"), 4)`) +}}) +``` + +`count_business_days("2026-02-21", "2026-03-01")` should return `5`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_business_days("2026-02-21", "2026-03-01"), 5)`) +}}) +``` + +`count_business_days("2026-03-08", "2026-03-17")` should return `7`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_business_days("2026-03-08", "2026-03-17"), 7)`) +}}) +``` + +`count_business_days("2026-02-24", "2027-02-24")` should return `262`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_business_days("2026-02-24", "2027-02-24"), 262)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def count_business_days(start, end): + + return start +``` + +# --solutions-- + +```py +from datetime import datetime, timedelta + +def count_business_days(start, end): + start_date = datetime.strptime(start, "%Y-%m-%d") + end_date = datetime.strptime(end, "%Y-%m-%d") + + count = 0 + current = start_date + + while current <= end_date: + if current.weekday() < 5: + count += 1 + current += timedelta(days=1) + + return count +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa2.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa2.md new file mode 100644 index 00000000000..3c6e760d86d --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa2.md @@ -0,0 +1,86 @@ +--- +id: 698a1a73ade5ac0e19180fa2 +title: "Challenge 199: Sequential Difference" +challengeType: 29 +dashedName: challenge-199 +--- + +# --description-- + +Given an array of numbers, return a new array containing the value needed to get from each number to the next number. + +- For the last number, use `0` since there is no next number. + +For example, given `[1, 2, 4, 7]`, return `[1, 2, 3, 0]`. + +# --hints-- + +`find_differences([1, 2, 4, 7])` should return `[1, 2, 3, 0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(find_differences([1, 2, 4, 7]), [1, 2, 3, 0])`) +}}) +``` + +`find_differences([10, 15, 19, 22, 24, 25])` should return `[5, 4, 3, 2, 1, 0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(find_differences([10, 15, 19, 22, 24, 25]), [5, 4, 3, 2, 1, 0])`) +}}) +``` + +`find_differences([25, 20, 16, 13, 11, 10])` should return `[-5, -4, -3, -2, -1, 0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(find_differences([25, 20, 16, 13, 11, 10]), [-5, -4, -3, -2, -1, 0])`) +}}) +``` + +`find_differences([0, 1, 2, 2, 3, 3, 4, 5])` should return `[1, 1, 0, 1, 0, 1, 1, 0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(find_differences([0, 1, 2, 2, 3, 3, 4, 5]), [1, 1, 0, 1, 0, 1, 1, 0])`) +}}) +``` + +`find_differences([1, 2, 5, 12, 34, -15, -1, 41, 113, -222, -99, -40, 10, -18, -6, -2, -1])` should return `[1, 3, 7, 22, -49, 14, 42, 72, -335, 123, 59, 50, -28, 12, 4, 1, 0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(find_differences([1, 2, 5, 12, 34, -15, -1, 41, 113, -222, -99, -40, 10, -18, -6, -2, -1]), [1, 3, 7, 22, -49, 14, 42, 72, -335, 123, 59, 50, -28, 12, 4, 1, 0])`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def find_differences(arr): + + return arr +``` + +# --solutions-- + +```py +def find_differences(arr): + result = [] + + for i in range(len(arr)): + if i == len(arr) - 1: + result.append(0) + else: + result.append(arr[i + 1] - arr[i]) + + return result +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa3.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa3.md new file mode 100644 index 00000000000..92653ce3a82 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa3.md @@ -0,0 +1,92 @@ +--- +id: 698a1a73ade5ac0e19180fa3 +title: "Challenge 200: Letter and Number Count" +challengeType: 29 +dashedName: challenge-200 +--- + +# --description-- + +Given a string, return a message with the count of how many letters and numbers it contains. + +- Letters are `A-Z` and `a-z`. +- Numbers are `0-9`. +- Ignore all other characters. + +Return `"The string has X letters and Y numbers."`, where `"X"` is the count of letters and `"Y"` is the count of numbers. If either count is 1, use the singular form for that item. E.g: `"1 letter"` instead of `"1 letters"` and `"1 number"` instead of `"1 numbers"`. + +# --hints-- + +`count_letters_and_numbers("helloworld123")` should return `"The string has 10 letters and 3 numbers."`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_letters_and_numbers("helloworld123"), "The string has 10 letters and 3 numbers.")`) +}}) +``` + +`count_letters_and_numbers("Catch 22")` should return `"The string has 5 letters and 2 numbers."`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_letters_and_numbers("Catch 22"), "The string has 5 letters and 2 numbers.")`) +}}) +``` + +`count_letters_and_numbers("A1!")` should return `"The string has 1 letter and 1 number."`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_letters_and_numbers("A1!"), "The string has 1 letter and 1 number.")`) +}}) +``` + +`count_letters_and_numbers("12345")` should return `"The string has 0 letters and 5 numbers."`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_letters_and_numbers("12345"), "The string has 0 letters and 5 numbers.")`) +}}) +``` + +`count_letters_and_numbers("password")` should return `"The string has 8 letters and 0 numbers."`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_letters_and_numbers("password"), "The string has 8 letters and 0 numbers.")`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def count_letters_and_numbers(s): + + return s +``` + +# --solutions-- + +```py +def count_letters_and_numbers(s): + letter_count = 0 + number_count = 0 + + for char in s: + if ('A' <= char <= 'Z') or ('a' <= char <= 'z'): + letter_count += 1 + elif '0' <= char <= '9': + number_count += 1 + + letter_word = "letter" if letter_count == 1 else "letters" + number_word = "number" if number_count == 1 else "numbers" + + return f"The string has {letter_count} {letter_word} and {number_count} {number_word}." +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa4.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa4.md new file mode 100644 index 00000000000..5da9fac58c6 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa4.md @@ -0,0 +1,121 @@ +--- +id: 698a1a73ade5ac0e19180fa4 +title: "Challenge 201: Matrix Shift" +challengeType: 29 +dashedName: challenge-201 +--- + +# --description-- + +Given a matrix (array of arrays) of numbers and an integer, shift all values in the matrix by the given amount. + +- A positive shift moves values to the right. +- A negative shift moves values to the left. + +Values should wrap: + +- Treat the matrix as one continuous sequence of values. +- When a value moves past the end of a row, it continues at the beginning of the next row. +- When a value moves past the last position in the matrix, it wraps to the first position. +- The same applies in reverse when shifting left. + +For example, given: + +```js +[ + [1, 2, 3], + [4, 5, 6] +] +``` + +with a shift of `1`, move all the numbers to the right one: + +```js +[ + [6, 1, 2], + [3, 4, 5] +] +``` + +# --hints-- + +`shift_matrix([[1, 2, 3], [4, 5, 6]], 1)` should return `[[6, 1, 2], [3, 4, 5]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3], [4, 5, 6]], 1), [[6, 1, 2], [3, 4, 5]])`) +}}) +``` + +`shift_matrix([[1, 2, 3], [4, 5, 6]], -1)` should return `[[2, 3, 4], [5, 6, 1]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3], [4, 5, 6]], -1), [[2, 3, 4], [5, 6, 1]])`) +}}) +``` + +`shift_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 5)` should return `[[5, 6, 7], [8, 9, 1], [2, 3, 4]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 5), [[5, 6, 7], [8, 9, 1], [2, 3, 4]])`) +}}) +``` + +`shift_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], -6)` should return `[[7, 8, 9], [1, 2, 3], [4, 5, 6]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]], -6), [[7, 8, 9], [1, 2, 3], [4, 5, 6]])`) +}}) +``` + +`shift_matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 7)` should return `[[10, 11, 12, 13], [14, 15, 16, 1], [2, 3, 4, 5], [6, 7, 8, 9]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], 7), [[10, 11, 12, 13], [14, 15, 16, 1], [2, 3, 4, 5], [6, 7, 8, 9]])`) +}}) +``` + +`shift_matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], -54)` should return `[[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 1, 2], [3, 4, 5, 6]]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(shift_matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]], -54), [[7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 1, 2], [3, 4, 5, 6]])`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def shift_matrix(matrix, shift): + + return matrix +``` + +# --solutions-- + +```py +def shift_matrix(matrix, shift): + rows = len(matrix) + cols = len(matrix[0]) + flat = [num for row in matrix for num in row] + n = len(flat) + s = shift % n + shifted = flat[-s:] + flat[:-s] if s != 0 else flat[:] + result = [] + for i in range(rows): + result.append(shifted[i*cols:(i+1)*cols]) + + return result +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa5.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa5.md new file mode 100644 index 00000000000..95a659a25a9 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa5.md @@ -0,0 +1,90 @@ +--- +id: 698a1a73ade5ac0e19180fa5 +title: "Challenge 202: Add Punctuation" +challengeType: 29 +dashedName: challenge-202 +--- + +# --description-- + +Given a string of sentences with missing periods, add a period (`"."`) in the following places: + +- Before each space that comes immediately before an uppercase letter +- And at the end of the string + +Return the resulting string. + +# --hints-- + +`add_punctuation("Hello world")` should return `"Hello world."` + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(add_punctuation("Hello world"), "Hello world.")`) +}}) +``` + +`add_punctuation("Hello world It's nice today")` should return `"Hello world. It's nice today."` + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(add_punctuation("Hello world It's nice today"), "Hello world. It's nice today.")`) +}}) +``` + +`add_punctuation("JavaScript is great Sometimes")` should return `"JavaScript is great. Sometimes."` + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(add_punctuation("JavaScript is great Sometimes"), "JavaScript is great. Sometimes.")`) +}}) +``` + +`add_punctuation("A b c D e F g h I J k L m n o P Q r S t U v w X Y Z")` should return `"A b c. D e. F g h. I. J k. L m n o. P. Q r. S t. U v w. X. Y. Z."` + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(add_punctuation("A b c D e F g h I J k L m n o P Q r S t U v w X Y Z"), "A b c. D e. F g h. I. J k. L m n o. P. Q r. S t. U v w. X. Y. Z.")`) +}}) +``` + +`add_punctuation("Wait.. For it")` should return `"Wait... For it."` + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(add_punctuation("Wait.. For it"), "Wait... For it.")`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_punctuation(sentences): + + return sentences +``` + +# --solutions-- + +```py +def add_punctuation(sentences): + result = "" + length = len(sentences) + + for i, c in enumerate(sentences): + if c == " " and i + 1 < length and sentences[i + 1].isupper(): + result += "." + result += c + + if not result.endswith("."): + result += "." + + return result +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa6.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa6.md new file mode 100644 index 00000000000..bfaa71946ce --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa6.md @@ -0,0 +1,79 @@ +--- +id: 698a1a73ade5ac0e19180fa6 +title: "Challenge 203: Flattened" +challengeType: 29 +dashedName: challenge-203 +--- + +# --description-- + +Given an array, determine if it is flat. + +- An array is flat if none of its elements are arrays. + +# --hints-- + +`is_flat([1, 2, 3, 4])` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_flat([1, 2, 3, 4]), True)`) +}}) +``` + +`is_flat([1, [2, 3], 4])` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_flat([1, [2, 3], 4]), False)`) +}}) +``` + +`is_flat([1, 0, False, True, "a", "b"])` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_flat([1, 0, False, True, "a", "b"]), True)`) +}}) +``` + +`is_flat(["a", [0], "b", True])` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_flat(["a", [0], "b", True]), False)`) +}}) +``` + +`is_flat([1, [2, [3, [4, [5]]]], 6])` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_flat([1, [2, [3, [4, [5]]]], 6]), False)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def is_flat(arr): + + return arr +``` + +# --solutions-- + +```py +def is_flat(arr): + for el in arr: + if isinstance(el, list): + return False + return True +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa7.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa7.md new file mode 100644 index 00000000000..127297af693 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa7.md @@ -0,0 +1,84 @@ +--- +id: 698a1a73ade5ac0e19180fa7 +title: "Challenge 204: Sum the Letters" +challengeType: 29 +dashedName: challenge-204 +--- + +# --description-- + +Given a string, return the sum of its letters. + +- Letters are A-Z in uppercase or lowercase +- Letter values are: `"A"` = 1, `"B"` = 2, ..., `"Z"` = 26 +- Uppercase and lowercase letters have the same value. +- Ignore all non-letter characters. + +# --hints-- + +`sum_letters("Hello")` should return `52`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_letters("Hello"), 52)`) +}}) +``` + +`sum_letters("freeCodeCamp")` should return `94`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_letters("freeCodeCamp"), 94)`) +}}) +``` + +`sum_letters("The quick brown fox jumps over the lazy dog.")` should return `473`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_letters("The quick brown fox jumps over the lazy dog."), 473)`) +}}) +``` + +`sum_letters("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ex nisl, pretium eu varius blandit, facilisis quis eros. Vestibulum ante ipsum primis in faucibus orci.")` should return `1681`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_letters("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ex nisl, pretium eu varius blandit, facilisis quis eros. Vestibulum ante ipsum primis in faucibus orci."), 1681)`) +}}) +``` + +`sum_letters("")` should return `0`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_letters(""), 0)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def sum_letters(s): + + return s +``` + +# --solutions-- + +```py +def sum_letters(s): + total = 0 + for char in s: + upper = char.upper() + if 'A' <= upper <= 'Z': + total += ord(upper) - ord('A') + 1 + return total +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa8.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa8.md new file mode 100644 index 00000000000..1789003e8c0 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa8.md @@ -0,0 +1,92 @@ +--- +id: 698a1a73ade5ac0e19180fa8 +title: "Challenge 205: Perfect Cube Count" +challengeType: 29 +dashedName: challenge-205 +--- + +# --description-- + +Given two integers, determine how many perfect cubes exist in the range between and including the two numbers. + +- The lower number is not garanteed to be the first argument. +- A number is a perfect cube if there exists an integer (`n`) where `n * n * n = number`. For example, 27 is a perfect cube because `3 * 3 * 3 = 27`. + +# --hints-- + +`count_perfect_cubes(3, 30)` should return `2`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_perfect_cubes(3, 30), 2)`) +}}) +``` + +`count_perfect_cubes(1, 30)` should return `3`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_perfect_cubes(1, 30), 3)`) +}}) +``` + +`count_perfect_cubes(30, 0)` should return `4`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_perfect_cubes(30, 0), 4)`) +}}) +``` + +`count_perfect_cubes(-64, 64)` should return `9`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_perfect_cubes(-64, 64), 9)`) +}}) +``` + +`count_perfect_cubes(9214, -8127)` should return `41`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(count_perfect_cubes(9214, -8127), 41)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def count_perfect_cubes(a, b): + + return a +``` + +# --solutions-- + +```py +def count_perfect_cubes(a, b): + start, end = min(a, b), max(a, b) + count = 0 + + n = 0 + while n ** 3 <= end: + if n ** 3 >= start: + count += 1 + n += 1 + + n = -1 + while n ** 3 >= start: + if n ** 3 <= end: + count += 1 + n -= 1 + + return count +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa9.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa9.md new file mode 100644 index 00000000000..e18d64f79fb --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a73ade5ac0e19180fa9.md @@ -0,0 +1,100 @@ +--- +id: 698a1a73ade5ac0e19180fa9 +title: "Challenge 206: Playing Card Values" +challengeType: 29 +dashedName: challenge-206 +--- + +# --description-- + +Given an array of playing cards, return a new array with the numeric value of each card. + +Card Values: + +- An Ace (`"A"`) has a value of 1. +- Numbered cards (`"2"` - `"10"`) have their face value: 2 - 10, respectively. +- Face cards: Jack (`"J"`), Queen (`"Q"`), and King (`"K"`) are each worth 10. + +Suits: + +- Each card has a suit: Spades (`"S"`), Clubs (`"C"`), Diamonds (`"D"`), or Hearts (`"H"`). + +Card Format: + +- Each card is represented as a string: `"valueSuit"`. For Example: `"AS"` is the Ace of Spades, `"10H"` is the Ten of Hearts, and `"QC"` is the Queen of Clubs. + +# --hints-- + +`card_values(["3H", "4D", "5S"])` should return `[3, 4, 5]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(card_values(["3H", "4D", "5S"]), [3, 4, 5])`) +}}) +``` + +`card_values(["AS", "10S", "10H", "6D", "7D"])` should return `[1, 10, 10, 6, 7]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(card_values(["AS", "10S", "10H", "6D", "7D"]), [1, 10, 10, 6, 7])`) +}}) +``` + +`card_values(["8D", "QS", "2H", "JC", "9C"])` should return `[8, 10, 2, 10, 9]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(card_values(["8D", "QS", "2H", "JC", "9C"]), [8, 10, 2, 10, 9])`) +}}) +``` + +`card_values(["AS", "KS"])` should return `[1, 10]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(card_values(["AS", "KS"]), [1, 10])`) +}}) +``` + +`card_values(["10H", "JH", "QH", "KH", "AH"])` should return `[10, 10, 10, 10, 1]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(card_values(["10H", "JH", "QH", "KH", "AH"]), [10, 10, 10, 10, 1])`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def card_values(cards): + + return cards +``` + +# --solutions-- + +```py +def card_values(cards): + values = [] + for card in cards: + value_str = card[:-1] + + if value_str == "A": + value = 1 + elif value_str in ["J", "Q", "K"]: + value = 10 + else: + value = int(value_str) + + values.append(value) + return values +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645e.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645e.md new file mode 100644 index 00000000000..0cd5e60703e --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645e.md @@ -0,0 +1,98 @@ +--- +id: 698a1a863194f1f4e63f645e +title: "Challenge 207: Smallest Gap" +challengeType: 29 +dashedName: challenge-207 +--- + +# --description-- + +Given a string, return the substring between the two identical characters that have the smallest number of characters between them (smallest gap). + +- There will always be at least one pair of matching characters. +- The returned substring should exclude the matching characters. +- If two or more gaps are the same length, return the characters from the first one. + +For example, given `"ABCDAC"`, return `"DA"`. + +- Only `"A"` and `"C"` repeat in the string. +- The number of characters between the two `"A"` characters is 3, and between the `"C"` characters is 2. +- So return the string between the two `"C"` characters. + +# --hints-- + +`smallest_gap("ABCDAC")` should return `"DA"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(smallest_gap("ABCDAC"), "DA")`) +}}) +``` + +`smallest_gap("racecar")` should return `"e"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(smallest_gap("racecar"), "e")`) +}}) +``` + +`smallest_gap("A{5e^SD*F4i!o#q6e&rkf(po8|we9+kr-2!3}=4")` should return `"#q6e&rkf(p"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(smallest_gap("A{5e^SD*F4i!o#q6e&rkf(po8|we9+kr-2!3}=4"), "#q6e&rkf(p")`) +}}) +``` + +`smallest_gap("Hello World")` should return `""`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(smallest_gap("Hello World"), "")`) +}}) +``` + +`smallest_gap("The quick brown fox jumps over the lazy dog.")` should return `"fox"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(smallest_gap("The quick brown fox jumps over the lazy dog."), "fox")`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def smallest_gap(s): + + return s +``` + +# --solutions-- + +```py +def smallest_gap(s): + min_gap = float("inf") + result = "" + + for i in range(len(s)): + for j in range(i + 1, len(s)): + if s[i] == s[j]: + gap = j - i - 1 + + if gap < min_gap: + min_gap = gap + result = s[i + 1:j] + + break + + return result +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645f.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645f.md new file mode 100644 index 00000000000..8f43b31816b --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f645f.md @@ -0,0 +1,140 @@ +--- +id: 698a1a863194f1f4e63f645f +title: "Challenge 208: Trail Traversal" +challengeType: 29 +dashedName: challenge-208 +--- + +# --description-- + +Given an array of strings representing your trail map, return a string of the moves needed to get to your goal. + +The given strings will contain the values: + +- `"C"`: Your current location +- `"G"`: Your goal +- `"T"`: Traversable parts of the trail +- `"-"`: Untraversable parts of the map + +Return a string with the moves needed to follow the trail from your location to your goal where: + +- `"R"` is a move right +- `"D"` is a move down +- `"L"` is a move left +- `"U"` is a move up + +- There will always be a single continuous trail, without any branching, from your current location to your goal. +- Each trail location will have a maximum of two traversable locations touching it. + +For example, given: + +```js +[ + "-CT--", + "--T--", + "--TT-", + "---T-", + "---G-" +] +``` + +Return `"RDDRDD"`. + +# --hints-- + +`navigate_trail(["-CT--", "--T--", "--TT-", "---T-", "---G-"])` should return `"RDDRDD"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(navigate_trail(["-CT--", "--T--", "--TT-", "---T-", "---G-"]), "RDDRDD")`) +}}) +``` + +`navigate_trail(["-----", "--TTG", "--T--", "--T--", "CTT--"])` should return `"RRUUURR"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(navigate_trail(["-----", "--TTG", "--T--", "--T--", "CTT--"]), "RRUUURR")`) +}}) +``` + +`navigate_trail(["-C----", "TT----", "T-----", "TTTTT-", "----G-"])` should return `"DLDDRRRRD"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(navigate_trail(["-C----", "TT----", "T-----", "TTTTT-", "----G-"]), "DLDDRRRRD")`) +}}) +``` + +`navigate_trail(["--------", "-CTTT---", "----T---", "---GT---", "--------"])` should return `"RRRDDL"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(navigate_trail(["--------", "-CTTT---", "----T---", "---GT---", "--------"]), "RRRDDL")`) +}}) +``` + +`navigate_trail(["TTTTTTT-", "T-----T-", "T-----T-", "TTTT--TG", "---C----"])` should return `"ULLLUUURRRRRRDDDR"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(navigate_trail(["TTTTTTT-", "T-----T-", "T-----T-", "TTTT--TG", "---C----"]), "ULLLUUURRRRRRDDDR")`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def navigate_trail(map): + + return map +``` + +# --solutions-- + +```py +def navigate_trail(map): + rows = len(map) + cols = len(map[0]) + + directions = [ + (0, 1, "R"), + (1, 0, "D"), + (0, -1, "L"), + (-1, 0, "U"), + ] + + for r in range(rows): + for c in range(cols): + if map[r][c] == "C": + row, col = r, c + + result = "" + prev = None + + while map[row][col] != "G": + for dr, dc, move in directions: + new_row = row + dr + new_col = col + dc + + if ( + 0 <= new_row < rows and + 0 <= new_col < cols and + (map[new_row][new_col] == "T" or + map[new_row][new_col] == "G") and + (not prev or (new_row, new_col) != prev) + ): + result += move + prev = (row, col) + row, col = new_row, new_col + break + + return result +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f6460.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f6460.md new file mode 100644 index 00000000000..90de625522d --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/698a1a863194f1f4e63f6460.md @@ -0,0 +1,96 @@ +--- +id: 698a1a863194f1f4e63f6460 +title: "Challenge 209: Element Size" +challengeType: 29 +dashedName: challenge-209 +--- + +# --description-- + +Given a window size, the width of an element in viewport width `"vw"` units, and the height of an element in viewport height `"vh"` units, determine the size of the element in pixels. + +- The given window size and returned element size are strings in the format `"width x height"`, `"1200 x 800"` for example. + +- `"vw"` units are the percent of window width. `"50vw"` for example, is 50% of the width of the window. +- `"vh"` units are the percent of window height. `"50vh"` for example, is 50% of the height of the window. + +# --hints-- + +`get_element_size("1200 x 800", "50vw", "50vh")` should return `"600 x 400"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("1200 x 800", "50vw", "50vh"), "600 x 400")`) +}}) +``` + +`get_element_size("320 x 480", "25vw", "50vh")` should return `"80 x 240"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("320 x 480", "25vw", "50vh"), "80 x 240")`) +}}) +``` + +`get_element_size("1000 x 500", "7vw", "3vh")` should return `"70 x 15"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("1000 x 500", "7vw", "3vh"), "70 x 15")`) +}}) +``` + +`get_element_size("1920 x 1080", "95vw", "100vh")` should return `"1824 x 1080"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("1920 x 1080", "95vw", "100vh"), "1824 x 1080")`) +}}) +``` + +`get_element_size("1200 x 800", "0vw", "0vh")` should return `"0 x 0"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("1200 x 800", "0vw", "0vh"), "0 x 0")`) +}}) +``` + +`get_element_size("1440 x 900", "100vw", "114vh")` should return `"1440 x 1026"`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(get_element_size("1440 x 900", "100vw", "114vh"), "1440 x 1026")`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def get_element_size(window_size, element_vw, element_vh): + + return window_size +``` + +# --solutions-- + +```py +def get_element_size(window_size, element_vw, element_vh): + window_width, window_height = map(int, window_size.split(" x ")) + + vw = int(element_vw.replace("vw", "")) + vh = int(element_vh.replace("vh", "")) + + width_px = round((vw / 100) * window_width) + height_px = round((vh / 100) * window_height) + + return f"{width_px} x {height_px}" +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f50f.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f50f.md new file mode 100644 index 00000000000..03484415079 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f50f.md @@ -0,0 +1,142 @@ +--- +id: 6994cff2290543b3aec9f50f +title: "Challenge 210: HSL Validator" +challengeType: 29 +dashedName: challenge-210 +--- + +# --description-- + +Given a string, determine whether it is a valid CSS `hsl()` color value. + +- A valid HSL value must be in the format `"hsl(h, s%, l%)"`, where: + - `h` (hue) must be a number between 0 and 360 (inclusive). + - `s` (saturation) must be a percentage between 0% and 100%. + - `l` (lightness) must be a percentage between 0% and 100%. + +- Spaces are only allowed: + - After the opening parenthesis + - Before and/or after the commas + - Before and/or after closing parenthesis + +- Optionally, the value can end with a semi-colon (`";"`). + +For example, `"hsl(240, 50%, 50%)"` is a valid HSL value. + +# --hints-- + +`is_valid_hsl("hsl(240, 50%, 50%)")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(240, 50%, 50%)"), True)`) +}}) +``` + +`is_valid_hsl("hsl( 200 , 50% , 75% )")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl( 200 , 50% , 75% )"), True)`) +}}) +``` + +`is_valid_hsl("hsl(99,60%,80%);")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(99,60%,80%);"), True)`) +}}) +``` + +`is_valid_hsl("hsl(0, 0%, 0%) ;")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(0, 0%, 0%) ;"), True)`) +}}) +``` + +`is_valid_hsl("hsl( 10 , 20% , 30% ) ;")` should return `True`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl( 10 , 20% , 30% ) ;"), True)`) +}}) +``` + +`is_valid_hsl("hsl(361, 50%, 80%)")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(361, 50%, 80%)"), False)`) +}}) +``` + +`is_valid_hsl("hsl(300, 101%, 70%)")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(300, 101%, 70%)"), False)`) +}}) +``` + +`is_valid_hsl("hsl(200, 55%, 75)")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl(200, 55%, 75)"), False)`) +}}) +``` + +`is_valid_hsl("hsl (80, 20%, 10%)")` should return `False`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertIs(is_valid_hsl("hsl (80, 20%, 10%)"), False)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def is_valid_hsl(hsl): + + return hsl +``` + +# --solutions-- + +```py +import re +def is_valid_hsl(hsl): + pattern = r"^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)\s*;?$" + + match = re.match(pattern, hsl) + if not match: + return False + + hue = int(match.group(1)) + sat = int(match.group(2)) + light = int(match.group(3)) + + if not (0 <= hue <= 360): + return False + if not (0 <= sat <= 100): + return False + if not (0 <= light <= 100): + return False + + return True +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f510.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f510.md new file mode 100644 index 00000000000..1d0e807cffc --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f510.md @@ -0,0 +1,75 @@ +--- +id: 6994cff2290543b3aec9f510 +title: "Challenge 211: Array Sum" +challengeType: 29 +dashedName: challenge-211 +--- + +# --description-- + +Given an array of numbers, return the sum of all the numbers. + +# --hints-- + +`sum_array([1, 2, 3, 4, 5])` should return `15`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_array([1, 2, 3, 4, 5]), 15)`) +}}) +``` + +`sum_array([42])` should return `42`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_array([42]), 42)`) +}}) +``` + +`sum_array([5, -2, 7, -3])` should return `7`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_array([5, -2, 7, -3]), 7)`) +}}) +``` + +`sum_array([203, 145, -129, 6293, 523, -919, 845, 2434])` should return `9395`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_array([203, 145, -129, 6293, 523, -919, 845, 2434]), 9395)`) +}}) +``` + +`sum_array([0, 0])` should return `0`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(sum_array([0, 0]), 0)`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def sum_array(numbers): + + return numbers +``` + +# --solutions-- + +```py +def sum_array(numbers): + + return sum(numbers) +``` diff --git a/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f511.md b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f511.md new file mode 100644 index 00000000000..f8237077f26 --- /dev/null +++ b/curriculum/challenges/english/blocks/daily-coding-challenges-python/6994cff2290543b3aec9f511.md @@ -0,0 +1,65 @@ +--- +id: 6994cff2290543b3aec9f511 +title: "Challenge 212: Array Insertion" +challengeType: 29 +dashedName: challenge-212 +--- + +# --description-- + +Given an array, a value to insert into the array, and an index to insert the value at, return a new array with the value inserted at the specified index. + +# --hints-- + +`insert_into_array([2, 4, 8, 10], 6, 2)` should return `[2, 4, 6, 8, 10]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(insert_into_array([2, 4, 8, 10], 6, 2), [2, 4, 6, 8, 10])`) +}}) +``` + +`insert_into_array(["the", "quick", "fox"], "brown", 2)` should return `["the", "quick", "brown", "fox"]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(insert_into_array(["the", "quick", "fox"], "brown", 2), ["the", "quick", "brown", "fox"])`) +}}) +``` + +`insert_into_array([], 0, 0)` should return `[0]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(insert_into_array([], 0, 0), [0])`) +}}) +``` + +`insert_into_array([0, 1, 1, 2, 3, 8, 13], 5, 5)` should return `[0, 1, 1, 2, 3, 5, 8, 13]`. + +```js +({test: () => { runPython(` +from unittest import TestCase +TestCase().assertEqual(insert_into_array([0, 1, 1, 2, 3, 8, 13], 5, 5), [0, 1, 1, 2, 3, 5, 8, 13])`) +}}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def insert_into_array(arr, value, index): + + return arr +``` + +# --solutions-- + +```py +def insert_into_array(arr, value, index): + return arr[:index] + [value] + arr[index:] +``` diff --git a/curriculum/structure/blocks/daily-coding-challenges-javascript.json b/curriculum/structure/blocks/daily-coding-challenges-javascript.json index ba66fd5d140..c7fba86fe87 100644 --- a/curriculum/structure/blocks/daily-coding-challenges-javascript.json +++ b/curriculum/structure/blocks/daily-coding-challenges-javascript.json @@ -790,6 +790,70 @@ { "id": "697a49e9860d24853adef681", "title": "Challenge 196: 2026 Winter Games Day 17: Closing Day" + }, + { + "id": "698a1a73ade5ac0e19180fa0", + "title": "Challenge 197: Blood Type Compatibility" + }, + { + "id": "698a1a73ade5ac0e19180fa1", + "title": "Challenge 198: Business Day Count" + }, + { + "id": "698a1a73ade5ac0e19180fa2", + "title": "Challenge 199: Sequential Difference" + }, + { + "id": "698a1a73ade5ac0e19180fa3", + "title": "Challenge 200: Letter and Number Count" + }, + { + "id": "698a1a73ade5ac0e19180fa4", + "title": "Challenge 201: Matrix Shift" + }, + { + "id": "698a1a73ade5ac0e19180fa5", + "title": "Challenge 202: Add Punctuation" + }, + { + "id": "698a1a73ade5ac0e19180fa6", + "title": "Challenge 203: Flattened" + }, + { + "id": "698a1a73ade5ac0e19180fa7", + "title": "Challenge 204: Sum the Letters" + }, + { + "id": "698a1a73ade5ac0e19180fa8", + "title": "Challenge 205: Perfect Cube Count" + }, + { + "id": "698a1a73ade5ac0e19180fa9", + "title": "Challenge 206: Playing Card Values" + }, + { + "id": "698a1a863194f1f4e63f645e", + "title": "Challenge 207: Smallest Gap" + }, + { + "id": "698a1a863194f1f4e63f645f", + "title": "Challenge 208: Trail Traversal" + }, + { + "id": "698a1a863194f1f4e63f6460", + "title": "Challenge 209: Element Size" + }, + { + "id": "6994cff2290543b3aec9f50f", + "title": "Challenge 210: HSL Validator" + }, + { + "id": "6994cff2290543b3aec9f510", + "title": "Challenge 211: Array Sum" + }, + { + "id": "6994cff2290543b3aec9f511", + "title": "Challenge 212: Array Insertion" } ] } diff --git a/curriculum/structure/blocks/daily-coding-challenges-python.json b/curriculum/structure/blocks/daily-coding-challenges-python.json index 641de92a9d1..e9ed05eec41 100644 --- a/curriculum/structure/blocks/daily-coding-challenges-python.json +++ b/curriculum/structure/blocks/daily-coding-challenges-python.json @@ -789,6 +789,70 @@ { "id": "697a49e9860d24853adef681", "title": "Challenge 196: 2026 Winter Games Day 17: Closing Day" + }, + { + "id": "698a1a73ade5ac0e19180fa0", + "title": "Challenge 197: Blood Type Compatibility" + }, + { + "id": "698a1a73ade5ac0e19180fa1", + "title": "Challenge 198: Business Day Count" + }, + { + "id": "698a1a73ade5ac0e19180fa2", + "title": "Challenge 199: Sequential Difference" + }, + { + "id": "698a1a73ade5ac0e19180fa3", + "title": "Challenge 200: Letter and Number Count" + }, + { + "id": "698a1a73ade5ac0e19180fa4", + "title": "Challenge 201: Matrix Shift" + }, + { + "id": "698a1a73ade5ac0e19180fa5", + "title": "Challenge 202: Add Punctuation" + }, + { + "id": "698a1a73ade5ac0e19180fa6", + "title": "Challenge 203: Flattened" + }, + { + "id": "698a1a73ade5ac0e19180fa7", + "title": "Challenge 204: Sum the Letters" + }, + { + "id": "698a1a73ade5ac0e19180fa8", + "title": "Challenge 205: Perfect Cube Count" + }, + { + "id": "698a1a73ade5ac0e19180fa9", + "title": "Challenge 206: Playing Card Values" + }, + { + "id": "698a1a863194f1f4e63f645e", + "title": "Challenge 207: Smallest Gap" + }, + { + "id": "698a1a863194f1f4e63f645f", + "title": "Challenge 208: Trail Traversal" + }, + { + "id": "698a1a863194f1f4e63f6460", + "title": "Challenge 209: Element Size" + }, + { + "id": "6994cff2290543b3aec9f50f", + "title": "Challenge 210: HSL Validator" + }, + { + "id": "6994cff2290543b3aec9f510", + "title": "Challenge 211: Array Sum" + }, + { + "id": "6994cff2290543b3aec9f511", + "title": "Challenge 212: Array Insertion" } ] } diff --git a/tools/daily-challenges/seed-daily-challenges.ts b/tools/daily-challenges/seed-daily-challenges.ts index 04029ed019a..fa957652fe2 100644 --- a/tools/daily-challenges/seed-daily-challenges.ts +++ b/tools/daily-challenges/seed-daily-challenges.ts @@ -13,7 +13,7 @@ const { MONGOHQ_URL } = process.env; // Number challenges in the dev-playground blocks // Update this if the number of challenges changes -const EXPECTED_CHALLENGE_COUNT = 196; +const EXPECTED_CHALLENGE_COUNT = 212; // Date to set for the first challenge, second challenge will be one day later, etc... // **DO NOT CHANGE THIS AFTER RELEASE (if seeding production - okay for local dev)**