diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-binary-search.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-binary-search.md index caa2c40514c..62e12ff1610 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-binary-search.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-binary-search.md @@ -41,18 +41,26 @@ const testArray = [ `binarySearch` should be a function. ```js -assert(typeof binarySearch == 'function'); +assert.isFunction(binarySearch); ``` `binarySearch(testArray, 0)` should return `[13, 5, 2, 0]`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.deepEqual(binarySearch(_testArray, 0), [13, 5, 2, 0]); ``` `binarySearch(testArray, 1)` should return `[13, 5, 2, 0, 1]`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.deepEqual(binarySearch(_testArray, 1), [13, 5, 2, 0, 1]); ``` @@ -60,44 +68,55 @@ assert.deepEqual(binarySearch(_testArray, 1), [13, 5, 2, 0, 1]); `binarySearch(testArray, 2)` should return `[13, 5, 2]`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.deepEqual(binarySearch(_testArray, 2), [13, 5, 2]); ``` `binarySearch(testArray, 6)` should return the string `Value Not Found`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.strictEqual(binarySearch(_testArray, 6), 'Value Not Found'); ``` `binarySearch(testArray, 11)` should return `[13, 5, 10, 11]`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.deepEqual(binarySearch(_testArray, 11), [13, 5, 10, 11]) ``` `binarySearch(testArray, 13)` should return `[13]`. ```js +const _testArray = [ + 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 49, 70 +]; assert.deepEqual(binarySearch(_testArray, 13), [13]); ``` `binarySearch(testArray, 70)` should return `[13, 19, 22, 49, 70]`. -```js -assert.deepEqual(binarySearch(_testArray, 70), [13, 19, 22, 49, 70]); -``` - -# --seed-- - -## --after-user-code-- - ```js const _testArray = [ 0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 49, 70 ]; +assert.deepEqual(binarySearch(_testArray, 70), [13, 19, 22, 49, 70]); ``` +# --seed-- + ## --seed-contents-- ```js diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-bubble-sort.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-bubble-sort.md index 8c53f812472..3fca81b8f73 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-bubble-sort.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-bubble-sort.md @@ -21,13 +21,19 @@ This method requires multiple iterations through the array and for average and w `bubbleSort` should be a function. ```js -assert(typeof bubbleSort == 'function'); +assert.isFunction(bubbleSort); ``` `bubbleSort` should return a sorted array (least to greatest). ```js -assert( +function isSorted(a){ + for(let i = 0; i < a.length - 1; i++) + if(a[i] > a[i + 1]) + return false; + return true; +} +assert.isTrue( isSorted( bubbleSort([ 1, @@ -82,21 +88,6 @@ assert.sameMembers( `bubbleSort` should not use the built-in `.sort()` method. ```js -assert.isFalse(isBuiltInSortUsed()); -``` - -# --seed-- - -## --after-user-code-- - -```js -function isSorted(a){ - for(let i = 0; i < a.length - 1; i++) - if(a[i] > a[i + 1]) - return false; - return true; -} - function isBuiltInSortUsed(){ let sortUsed = false; const temp = Array.prototype.sort; @@ -108,8 +99,11 @@ function isBuiltInSortUsed(){ } return sortUsed; } +assert.isFalse(isBuiltInSortUsed()); ``` +# --seed-- + ## --seed-contents-- ```js diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-insertion-sort.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-insertion-sort.md index 5c2edd68273..c6b2b3ec3a0 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-insertion-sort.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-insertion-sort.md @@ -17,13 +17,19 @@ The next sorting method we'll look at is insertion sort. This method works by bu `insertionSort` should be a function. ```js -assert(typeof insertionSort == 'function'); +assert.isFunction(insertionSort); ``` `insertionSort` should return a sorted array (least to greatest). ```js -assert( +function isSorted(a){ + for(let i = 0; i < a.length - 1; i++) + if(a[i] > a[i + 1]) + return false; + return true; +} +assert.isTrue( isSorted( insertionSort([ 1, @@ -84,21 +90,6 @@ assert.deepEqual(insertionSort([5, 4, 33, 2, 8]), [2, 4, 5, 8, 33]) `insertionSort` should not use the built-in `.sort()` method. ```js -assert.isFalse(isBuiltInSortUsed()); -``` - -# --seed-- - -## --after-user-code-- - -```js -function isSorted(a){ - for(let i = 0; i < a.length - 1; i++) - if(a[i] > a[i + 1]) - return false; - return true; -} - function isBuiltInSortUsed(){ let sortUsed = false; const temp = Array.prototype.sort; @@ -110,8 +101,11 @@ function isBuiltInSortUsed(){ } return sortUsed; } +assert.isFalse(isBuiltInSortUsed()); ``` +# --seed-- + ## --seed-contents-- ```js diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-merge-sort.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-merge-sort.md index 4320236fc3a..7980d96f6fe 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-merge-sort.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-merge-sort.md @@ -31,6 +31,12 @@ assert.isFunction(mergeSort); `mergeSort` should return a sorted array (least to greatest). ```js +function isSorted(a){ + for(let i = 0; i < a.length - 1; i++) + if(a[i] > a[i + 1]) + return false; + return true; +} assert.isTrue( isSorted( mergeSort([ @@ -86,21 +92,6 @@ assert.sameMembers( `mergeSort` should not use the built-in `.sort()` method. ```js -assert.isFalse(isBuiltInSortUsed()); -``` - -# --seed-- - -## --after-user-code-- - -```js -function isSorted(a){ - for(let i = 0; i < a.length - 1; i++) - if(a[i] > a[i + 1]) - return false; - return true; -} - function isBuiltInSortUsed(){ let sortUsed = false; const temp = Array.prototype.sort; @@ -112,8 +103,11 @@ function isBuiltInSortUsed(){ } return sortUsed; } +assert.isFalse(isBuiltInSortUsed()); ``` +# --seed-- + ## --seed-contents-- ```js diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-quick-sort.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-quick-sort.md index 518c9fea14f..1327cb0f999 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-quick-sort.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-quick-sort.md @@ -25,7 +25,13 @@ assert(typeof quickSort == 'function'); `quickSort` should return a sorted array (least to greatest). ```js -assert( +function isSorted(a){ + for(let i = 0; i < a.length - 1; i++) + if(a[i] > a[i + 1]) + return false; + return true; +} +assert.isTrue( isSorted( quickSort([ 1, @@ -80,21 +86,6 @@ assert.sameMembers( `quickSort` should not use the built-in `.sort()` method. ```js -assert.isFalse(isBuiltInSortUsed()); -``` - -# --seed-- - -## --after-user-code-- - -```js -function isSorted(a){ - for(let i = 0; i < a.length - 1; i++) - if(a[i] > a[i + 1]) - return false; - return true; -} - function isBuiltInSortUsed(){ let sortUsed = false; const temp = Array.prototype.sort; @@ -106,8 +97,11 @@ function isBuiltInSortUsed(){ } return sortUsed; } +assert.isFalse(isBuiltInSortUsed()); ``` +# --seed-- + ## --seed-contents-- ```js diff --git a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-selection-sort.md b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-selection-sort.md index 334b9d43a75..ee22f5fd85c 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-selection-sort.md +++ b/curriculum/challenges/english/10-coding-interview-prep/algorithms/implement-selection-sort.md @@ -17,13 +17,20 @@ Here we will implement selection sort. Selection sort works by selecting the min `selectionSort` should be a function. ```js -assert(typeof selectionSort == 'function'); +assert.isFunction(selectionSort); ``` `selectionSort` should return a sorted array (least to greatest). ```js -assert( +function isSorted(a){ + for(let i = 0; i < a.length - 1; i++) + if(a[i] > a[i + 1]) + return false; + return true; +} + +assert.isTrue( isSorted( selectionSort([ 1, @@ -78,21 +85,6 @@ assert.sameMembers( `selectionSort` should not use the built-in `.sort()` method. ```js -assert.isFalse(isBuiltInSortUsed()); -``` - -# --seed-- - -## --after-user-code-- - -```js -function isSorted(a){ - for(let i = 0; i < a.length - 1; i++) - if(a[i] > a[i + 1]) - return false; - return true; -} - function isBuiltInSortUsed(){ let sortUsed = false; const temp = Array.prototype.sort; @@ -104,8 +96,11 @@ function isBuiltInSortUsed(){ } return sortUsed; } +assert.isFalse(isBuiltInSortUsed()); ``` +# --seed-- + ## --seed-contents-- ```js