diff --git a/package-lock.json b/package-lock.json index 47e03aa..8bcfbcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@emotion/react": "^11.11.3", "@monaco-editor/react": "^4.7.0", - "@nss-workshops/nss-core": "0.2.23", + "@nss-workshops/nss-core": "0.2.24", "@testing-library/react": "^16.2.0", "canvas-confetti": "^1.9.3", "chalk": "^5.6.2", @@ -71,9 +71,9 @@ } }, "node_modules/@asamuzakjp/css-color/node_modules/lru-cache": { - "version": "11.2.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz", - "integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==", + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", "license": "BlueOak-1.0.0", "engines": { "node": "20 || >=22" @@ -93,9 +93,9 @@ } }, "node_modules/@asamuzakjp/dom-selector/node_modules/lru-cache": { - "version": "11.2.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz", - "integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==", + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", "license": "BlueOak-1.0.0", "engines": { "node": "20 || >=22" @@ -480,9 +480,9 @@ } }, "node_modules/@csstools/css-calc": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.0.0.tgz", - "integrity": "sha512-q4d82GTl8BIlh/dTnVsWmxnbWJeb3kiU8eUH71UxlxnS+WIaALmtzTL8gR15PkYOexMQYVk0CO4qIG93C1IvPA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.0.1.tgz", + "integrity": "sha512-bsDKIP6f4ta2DO9t+rAbSSwv4EMESXy5ZIvzQl1afmD6Z1XHkVu9ijcG9QR/qSgQS1dVa+RaQ/MfQ7FIB/Dn1Q==", "funding": [ { "type": "github", @@ -552,9 +552,9 @@ } }, "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.0.26", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.0.26.tgz", - "integrity": "sha512-6boXK0KkzT5u5xOgF6TKB+CLq9SOpEGmkZw0g5n9/7yg85wab3UzSxB8TxhLJ31L4SGJ6BCFRw/iftTha1CJXA==", + "version": "1.0.27", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.0.27.tgz", + "integrity": "sha512-sxP33Jwg1bviSUXAV43cVYdmjt2TLnLXNqCWl9xmxHawWVjGz/kEbdkr7F9pxJNBN2Mh+dq0crgItbW6tQvyow==", "funding": [ { "type": "github", @@ -1517,9 +1517,9 @@ } }, "node_modules/@nss-workshops/nss-core": { - "version": "0.2.23", - "resolved": "https://npm.pkg.github.com/download/@nss-workshops/nss-core/0.2.23/1084218de617605b6f6d14332e6fe5d56bda91de", - "integrity": "sha512-xTEyM2UVTtKRTLD6cOAXYbR1A9SEN/VcKn46JOdnjNCLDoJk37qIgsXDor7b7hboK+Re8Nz3DrI8Wwls97MubA==", + "version": "0.2.24", + "resolved": "https://npm.pkg.github.com/download/@nss-workshops/nss-core/0.2.24/abff7fb26af9e8b5080206b9c454c44d0a313c1d", + "integrity": "sha512-iMQeQ2ROiPut18T5UFdIyohyf8mWs/VkXhm+ljXWQ4/YS7kjN0Ru5sMM2tAmGFL5X5MMXJc3R4Q+QOS1XW1F6w==", "engines": { "node": ">=18" }, @@ -2315,9 +2315,9 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "19.2.13", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.13.tgz", - "integrity": "sha512-KkiJeU6VbYbUOp5ITMIc7kBfqlYkKA5KhEHVrGMmUUMt7NeaZg65ojdPk+FtNrBAOXNVM5QM72jnADjM+XVRAQ==", + "version": "19.2.14", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz", + "integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==", "devOptional": true, "license": "MIT", "dependencies": { @@ -2814,9 +2814,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001768", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001768.tgz", - "integrity": "sha512-qY3aDRZC5nWPgHUgIB84WL+nySuo19wk0VJpp/XI9T34lrvkyhRvNVOFJOp2kxClQhiFBu+TaUSudf6oa3vkSA==", + "version": "1.0.30001769", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001769.tgz", + "integrity": "sha512-BCfFL1sHijQlBGWBMuJyhZUhzo7wer5sVj9hqekB/7xn0Ypy+pER/edCYQm4exbXj4WiySGp40P8UuTh6w1srg==", "dev": true, "funding": [ { @@ -3036,9 +3036,9 @@ } }, "node_modules/cssstyle/node_modules/lru-cache": { - "version": "11.2.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz", - "integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==", + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", "license": "BlueOak-1.0.0", "engines": { "node": "20 || >=22" @@ -5428,9 +5428,9 @@ } }, "node_modules/jackspeak": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.2.1.tgz", - "integrity": "sha512-GPBXyfcZSGujjddPeA+V34bW70ZJT7jzCEbloVasSH4yjiqWqXHX8iZQtZdVbOhc5esSeAIuiSmMutRZQB/olg==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.2.3.tgz", + "integrity": "sha512-ykkVRwrYvFm1nb2AJfKKYPr0emF6IiXDYUaFx4Zn9ZuIH7MrzEZ3sD5RlqGXNRpHtvUHJyOnCEFxOlNDtGo7wg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -6284,9 +6284,9 @@ } }, "node_modules/path-scurry/node_modules/lru-cache": { - "version": "11.2.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.5.tgz", - "integrity": "sha512-vFrFJkWtJvJnD5hg+hJvVE8Lh/TcMzKnTgCWmtBipwI5yLX/iX+5UB2tfuyODF5E7k9xEzMdYgGqaSb1c0c5Yw==", + "version": "11.2.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.6.tgz", + "integrity": "sha512-ESL2CrkS/2wTPfuend7Zhkzo2u0daGJ/A2VucJOgQ/C48S/zB8MMeMHSGKYpXhIjbPxfuezITkaBH1wqv00DDQ==", "dev": true, "license": "BlueOak-1.0.0", "engines": { @@ -7182,21 +7182,21 @@ } }, "node_modules/tldts": { - "version": "7.0.22", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.22.tgz", - "integrity": "sha512-nqpKFC53CgopKPjT6Wfb6tpIcZXHcI6G37hesvikhx0EmUGPkZrujRyAjgnmp1SHNgpQfKVanZ+KfpANFt2Hxw==", + "version": "7.0.23", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.0.23.tgz", + "integrity": "sha512-ASdhgQIBSay0R/eXggAkQ53G4nTJqTXqC2kbaBbdDwM7SkjyZyO0OaaN1/FH7U/yCeqOHDwFO5j8+Os/IS1dXw==", "license": "MIT", "dependencies": { - "tldts-core": "^7.0.22" + "tldts-core": "^7.0.23" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.0.22", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.22.tgz", - "integrity": "sha512-KgbTDC5wzlL6j/x6np6wCnDSMUq4kucHNm00KXPbfNzmllCmtmvtykJHfmgdHntwIeupW04y8s1N/43S1PkQDw==", + "version": "7.0.23", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.0.23.tgz", + "integrity": "sha512-0g9vrtDQLrNIiCj22HSe9d4mLVG3g5ph5DZ8zCKBr4OtrspmNB6ss7hVyzArAeE88ceZocIEGkyW1Ime7fxPtQ==", "license": "MIT" }, "node_modules/to-regex-range": { diff --git a/package.json b/package.json index ff4e872..6f72efd 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "preview": "vite preview" }, "dependencies": { - "@nss-workshops/nss-core": "0.2.23", + "@nss-workshops/nss-core": "0.2.24", "@emotion/react": "^11.11.3", "@monaco-editor/react": "^4.7.0", "@testing-library/react": "^16.2.0", diff --git a/src/sections/04-arrays-and-two-pointers/02-arrays-intro/index.md b/src/sections/04-arrays-and-two-pointers/02-arrays-intro/index.md index 638e26d..06e5cdd 100644 --- a/src/sections/04-arrays-and-two-pointers/02-arrays-intro/index.md +++ b/src/sections/04-arrays-and-two-pointers/02-arrays-intro/index.md @@ -86,9 +86,12 @@ console.log(mayasOrders.length); // 3 // ============================== ``` -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -148,9 +151,12 @@ orders.splice(0, 0, "Priority Order"); // Potentially slow with many orders // ============================== ``` -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -226,9 +232,12 @@ console.log(orders); // ["Second"] // ============================== ``` -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -304,9 +313,12 @@ processOrderQueue(mayasQueue); // ============================== ``` -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- diff --git a/src/sections/04-arrays-and-two-pointers/02-arrays-intro/starterCode.js b/src/sections/04-arrays-and-two-pointers/02-arrays-intro/starterCode.js index 80f841a..59d504d 100644 --- a/src/sections/04-arrays-and-two-pointers/02-arrays-intro/starterCode.js +++ b/src/sections/04-arrays-and-two-pointers/02-arrays-intro/starterCode.js @@ -2,7 +2,6 @@ // ============================== // Exercise 1: Help Maya Add Multiple Orders // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function \`addOrders\` that helps Maya add multiple orders to her array // The function should add: "Flat White", "Cold Brew", "Double Espresso" @@ -18,7 +17,6 @@ // ============================== // Exercise 2: Handle Priority Orders During Rush // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Help Maya insert two VIP orders at the front of her queue // Insert "VIP: Affogato" and "VIP: Cortado" at positions 0 and 1 @@ -32,7 +30,6 @@ // ============================== // Exercise 3: Fix Multiple Order Mistakes // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Maya made some mistakes! Help her fix them: // 1. Remove the two incorrect orders at indices 2 and 3 // 2. Update the first order from "Latter" to "Latte" @@ -46,7 +43,6 @@ // ============================== // Exercise 4: Create an Efficient Order Processing System // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Help Maya create a function that processes orders and shows progress // The function should loop through all orders and print each one with its position diff --git a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/index.md b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/index.md index afdcedd..64387fc 100644 --- a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/index.md +++ b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/index.md @@ -65,10 +65,13 @@ function findSongByTitle(setlist, title) { // Exercise 1: Help Alex Access Songs by Position // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! --- @@ -142,16 +145,19 @@ console.log(customSet); --- ## ⏱️ **Alex's Rehearsal Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== // Exercise 2: Help Alex Update Their Setlist // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -268,16 +274,18 @@ function carefulSongManagement() { --- ## ⏱️ **Alex's Performance Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== // Exercise 3: Help Alex Add Songs Strategically // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -398,16 +406,19 @@ console.log("Quick edits for efficiency, careful edits for artistry!"); --- ## ⏱️ **Alex's Late Night Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== // Exercise 4: Help Alex Remove Songs Strategically // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -550,16 +561,18 @@ console.log("Random inspiration:", alexsFinder.getRandomSong()); --- ## ⏱️ **Alex's Encore Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== // Exercise 5: Help Alex Find Songs for Requests // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -615,14 +628,4 @@ const song = setlist.find(s => s.mood === "romantic"); // Find by criteria 3. **Design your setlist structure** to favor the operations you'll use most frequently 4. **Batch similar operations** when possible to minimize disruption -### 🌟 **From Street Musician to Array Expert** - -Alex started the evening as a talented musician with a disorganized approach to setlist management. By the end of the night, they've not only delivered an amazing performance but also mastered the four core array operations that form the foundation of efficient programming. - -"The beautiful thing," Alex tells Marcus while settling up for the night, "is that these same principles apply whether you're managing songs, customer orders, inventory items, or any other collection of data. Once you understand access, update, add, and remove operations - and their performance characteristics - you can efficiently manage any array-based system." - -Marcus nods approvingly, "Same time next week?" - -Alex grins, slinging their guitar over their shoulder, "Absolutely. I've got some new songs to add to my repertoire - and I know exactly where to put them in my setlist for maximum impact!" - *Ready for the next challenge? Let's see how Alex uses these core operations to master advanced array methods and create even more sophisticated musical experiences...* \ No newline at end of file diff --git a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/solution.js b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/solution.js index 83b1253..da90600 100644 --- a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/solution.js +++ b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/solution.js @@ -4,6 +4,7 @@ function getSongAtPosition(setlist, position) { // Return the song at the given position // Handle invalid positions gracefully + // Return the string "Position out of bounds" if position is invalid if (position < 0 || position >= setlist.length) { return "Position out of bounds"; } diff --git a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/starterCode.js b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/starterCode.js index 3fb1fe4..191497e 100644 --- a/src/sections/04-arrays-and-two-pointers/03-array-core-operations/starterCode.js +++ b/src/sections/04-arrays-and-two-pointers/03-array-core-operations/starterCode.js @@ -1,12 +1,12 @@ // ============================== // Exercise 1: Help Alex Access Songs by Position // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function that helps Alex quickly access songs from their setlist // function getSongAtPosition(setlist, position) { // // Return the song at the given position // // Handle invalid positions gracefully +// // Return the string "Position out of bounds" if position is invalid // } // const alexsSetlist = ["Wonderwall", "Hotel California", "Blackbird", "Free Bird"]; @@ -16,12 +16,12 @@ // ============================== // Exercise 2: Help Alex Update Their Setlist // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function that updates multiple songs based on audience feedback // function updateSetlistBasedOnFeedback(setlist, updates) { // // updates is an object like { 0: "New Song", 2: "Another Song" } // // Update the setlist at the specified positions +// // Hint 1: Object keys are always returned as strings // return setlist; // } @@ -33,7 +33,6 @@ // ============================== // Exercise 3: Help Alex Add Songs Strategically // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function that adds songs using the most efficient method based on position // function addSongStrategically(setlist, song, position) { @@ -52,7 +51,6 @@ // ============================== // Exercise 4: Help Alex Remove Songs Strategically // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function that removes songs using the most efficient method // function removeSongStrategically(setlist, position) { @@ -71,7 +69,6 @@ // ============================== // Exercise 5: Help Alex Find Songs for Requests // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Create a function that finds songs matching specific criteria // function findSongsForRequest(repertoire, criteria) { diff --git a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/index.md b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/index.md index eda72b7..f89b977 100644 --- a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/index.md +++ b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/index.md @@ -94,10 +94,12 @@ visualizePriorityInsertion([...largeQueue], "VIP Order"); // Exercise 1: Measure the Impact of Scale // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -200,7 +202,7 @@ Maya studies the output. "Yes! The closer to the beginning we delete, the more o "Exactly! This is why we call it **O(n) time complexity** - the time it takes grows linearly with the number of elements that need to shift." --- -## ⏱️ **Maya's Deletion Detective Challenge!** +## ⏱️ **Maya's Deletion Detective Challenge!** - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== @@ -208,9 +210,13 @@ Maya studies the output. "Yes! The closer to the beginning we delete, the more o // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* + --- @@ -296,9 +302,13 @@ class SmartCoffeeQueue { // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* + --- @@ -400,9 +410,12 @@ PerformanceTester.compareStrategies(); // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- diff --git a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/solution.js b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/solution.js index baeb282..9d3af31 100644 --- a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/solution.js +++ b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/solution.js @@ -1,8 +1,9 @@ // ============================== // Exercise 1: Measure the Impact of Scale // ============================== +// No changes are neededβ€”just run the code and the tests, and observe the differences in timing. function measureInsertionScale() { - const sizes = [10, 100, 1000]; + const sizes = [10, 10_000, 1_000_000]; sizes.forEach(size => { // Create an array of the specified size diff --git a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/starterCode.js b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/starterCode.js index 7a45952..4292d0a 100644 --- a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/starterCode.js +++ b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/starterCode.js @@ -1,23 +1,21 @@ // ============================== // Exercise 1: Measure the Impact of Scale // ============================== -// Uncomment this block and click "Run Code" to complete the exercise -// Task: Create a function that demonstrates how insertion performance changes with array size -// Test insertion at the beginning with arrays of size 10, 100, and 1000 +// No changes are neededβ€”just run the code and the tests, and observe the differences in timing. function measureInsertionScale() { - const sizes = [10, 100, 1000]; - + const sizes = [10, 10_000, 1_000_000]; + sizes.forEach(size => { // Create an array of the specified size let testArray = Array.from({length: size}, (_, i) => `Order ${i + 1}`); - + // Measure performance by tracking operations const startTime = performance.now(); testArray.splice(0, 0, "Priority Order"); const endTime = performance.now(); const duration = (endTime - startTime).toFixed(3); - + console.log(`Insert at beginning - ${size} orders: ${duration}ms`); console.log(`Array size after insertion: ${testArray.length}`); console.log(`Elements that had to shift: ${size}`); @@ -25,18 +23,16 @@ function measureInsertionScale() { }); } -// measureInsertionScale(); +measureInsertionScale(); // ============================== // Exercise 2: Analyze Deletion Performance Patterns // ============================== -// Uncomment this block and click "Run Code" to complete the exercise -// Task: Create a function that shows how deletion position affects performance -// Delete from positions 0 (beginning), middle, and end of a 100-item array +// No changes are neededβ€”just run the code and the tests, and observe the differences in timing. function analyzeDeletionPatterns() { - const arraySize = 100; - + const arraySize = 1_000_000; + // Test deletion from beginning let array1 = Array.from({length: arraySize}, (_, i) => `Item ${i + 1}`); const elementsToShiftBeginning = arraySize - 1; @@ -47,7 +43,7 @@ function analyzeDeletionPatterns() { console.log(`Elements shifted: ${elementsToShiftBeginning}`); console.log(`Remaining items: ${array1.length}`); console.log("---"); - + // Test deletion from middle let array2 = Array.from({length: arraySize}, (_, i) => `Item ${i + 1}`); const middleIndex = Math.floor(arraySize / 2); @@ -59,7 +55,7 @@ function analyzeDeletionPatterns() { console.log(`Elements shifted: ${elementsToShiftMiddle}`); console.log(`Remaining items: ${array2.length}`); console.log("---"); - + // Test deletion from end let array3 = Array.from({length: arraySize}, (_, i) => `Item ${i + 1}`); const startTime3 = performance.now(); @@ -70,14 +66,14 @@ function analyzeDeletionPatterns() { console.log(`Remaining items: ${array3.length}`); } -// analyzeDeletionPatterns(); +analyzeDeletionPatterns(); // ============================== // Exercise 3: Build an Efficient Order Management System // ============================== -// Uncomment this block and click "Run Code" to complete the exercise -// Task: Create a class that manages orders efficiently using Maya's strategies -// Implement methods for adding regular orders, priority orders, and processing orders +// No changes are neededβ€”just run the code and the tests, +// , make sure you understand how the code works, +// comment out the driver (calling code) at the bottom class EfficientOrderManager { constructor() { @@ -157,7 +153,6 @@ class EfficientOrderManager { // ============================== // Exercise 4: Design a Performance-Optimized System // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Compare the performance of different approaches to handling 1000 orders // Measure the time difference between naive and optimized approaches diff --git a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/tests.js b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/tests.js index ba32d20..fbfb035 100644 --- a/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/tests.js +++ b/src/sections/04-arrays-and-two-pointers/04-array-tradeoffs/tests.js @@ -33,17 +33,17 @@ export const tests = [ // Verify that output was generated for different array sizes const hasSize10 = testResult.logOutput.some(line => line.includes('10 orders')); - const hasSize100 = testResult.logOutput.some(line => line.includes('100 orders')); - const hasSize1000 = testResult.logOutput.some(line => line.includes('1000 orders')); + const hasSize10000 = testResult.logOutput.some(line => line.includes('10000 orders')); + const hasSize1000000 = testResult.logOutput.some(line => line.includes('1000000 orders')); if (!hasSize10) { return { passed: false, message: "Should test with 10 orders" }; } - if (!hasSize100) { - return { passed: false, message: "Should test with 100 orders" }; + if (!hasSize10000) { + return { passed: false, message: "Should test with 10,000 orders" }; } - if (!hasSize1000) { - return { passed: false, message: "Should test with 1000 orders" }; + if (!hasSize1000000) { + return { passed: false, message: "Should test with 1,000,000 orders" }; } // Verify timing information is included diff --git a/src/sections/04-arrays-and-two-pointers/05-array-methods/index.md b/src/sections/04-arrays-and-two-pointers/05-array-methods/index.md index b979212..d8defb0 100644 --- a/src/sections/04-arrays-and-two-pointers/05-array-methods/index.md +++ b/src/sections/04-arrays-and-two-pointers/05-array-methods/index.md @@ -87,11 +87,12 @@ Alex adjusts their guitar strap, "That's because these operations are **O(n) tim // Exercise 1: Help Alex Manage Multiple Venue Setlists // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! - +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- ## Part 2: The Collaboration Coordinator - Transforming Data with map() and filter() @@ -208,16 +209,18 @@ rockFestivalSetlist.forEach(song => console.log(`- ${song.title}`)); --- ## ⏱️ **Alex's Collaboration Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: ```js // ============================== // Exercise 2: Help Alex Transform and Filter Song Collections // ============================== ``` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -400,16 +403,19 @@ Jordan nods approvingly, "So \`slice()\` lets you extract exactly the data you n --- ## ⏱️ **Alex's Data Analysis Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: \`\`\`js // ============================== // Exercise 3: Help Alex Analyze Performance Data // ============================== \`\`\` -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -588,17 +594,18 @@ Maya looks amazed, "So you can filter, transform, sort, and calculate all in one --- ## ⏱️ **Alex's Festival Curation Challenge!** - - πŸ”“ Uncomment this block and click "Run Code" to complete the exercise: + - πŸ”“ Uncomment the below code section in the editor πŸ‘‰: \`\`\`js // ============================== // Exercise 4: Help Alex Master Method Chaining and Advanced Array Operations // ============================== \`\`\` + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. -- Implement the required logic - - Click \`Run Code\` - - Inspect \`πŸ“‹ Console Output\` window for correctness! - +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- ## Alex's Array Mastery: From Street Musician to Data Wizard diff --git a/src/sections/04-arrays-and-two-pointers/06-implement-arraylist/index.md b/src/sections/04-arrays-and-two-pointers/06-implement-arraylist/index.md index d9f4183..cd34d19 100644 --- a/src/sections/04-arrays-and-two-pointers/06-implement-arraylist/index.md +++ b/src/sections/04-arrays-and-two-pointers/06-implement-arraylist/index.md @@ -293,9 +293,12 @@ console.log(` Memory efficiency: ${(audioBuffer.size() * 4 / (audioBuffer.capac // ============================== ``` -- Implement the required methods - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- diff --git a/src/sections/04-arrays-and-two-pointers/07-two-pointers/index.md b/src/sections/04-arrays-and-two-pointers/07-two-pointers/index.md index 031c439..d09c0e6 100644 --- a/src/sections/04-arrays-and-two-pointers/07-two-pointers/index.md +++ b/src/sections/04-arrays-and-two-pointers/07-two-pointers/index.md @@ -77,10 +77,12 @@ This **converging pointers** technique transforms an **O(nΒ²)** brute force appr // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- ## Part 2: The Catalog Survey - Fast and Slow Pointers @@ -258,9 +260,12 @@ This **fast and slow pointers** technique excels at: // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -397,9 +402,12 @@ The **sliding window** technique transforms **O(nΒ²)** nested loops into **O(n)* // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- @@ -487,9 +495,12 @@ truePalindromes.forEach(p => console.log(` - ${p.title}`)); // ============================== ``` -- Implement the required logic - - Click `Run Code` - - Inspect `πŸ“‹ Console Output` window for correctness! + - Read the requirements written as comments in the code. + - Implement the required logic. + - Click `Run Code` and inspect `πŸ“‹ Console Output` window for correctness! + - Click `Run Tests`and ensure that test(s) related to this specific exercise are passing Passing test will show in green text. + +🚧 *Some tests for future exercises may fail at first β€” that’s expected. As you complete each exercise, those tests will start passing. By the time you finish the final exercise, all tests in the test suite should pass.* --- diff --git a/src/sections/04-arrays-and-two-pointers/07-two-pointers/starterCode.js b/src/sections/04-arrays-and-two-pointers/07-two-pointers/starterCode.js index 018f9bc..f03ac6a 100644 --- a/src/sections/04-arrays-and-two-pointers/07-two-pointers/starterCode.js +++ b/src/sections/04-arrays-and-two-pointers/07-two-pointers/starterCode.js @@ -1,7 +1,6 @@ // ============================== // Exercise 1: Help Eleanor Find Book Pairs // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Find two books whose publication years sum to a target year // function findBookPairForTargetYear(bookYears, targetYear) { @@ -16,7 +15,6 @@ // ============================== // Exercise 2: Help Eleanor Detect Patterns // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Find the middle book in a reading list and detect if a list has cycles // function findMiddleBookInList(bookList) { @@ -37,7 +35,6 @@ // ============================== // Exercise 3: Help Eleanor Analyze Book Sequences // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Find the best consecutive sequence of books based on popularity scores // function findBestBookSequence(popularityScores, sequenceLength) { @@ -57,7 +54,6 @@ // ============================== // Exercise 4: Help Eleanor Solve Palindrome Mysteries // ============================== -// Uncomment this block and click "Run Code" to complete the exercise // Task: Check if book titles are palindromes and find the longest palindromic substring // function isPalindrome(text) {