diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/soundex.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/soundex.md index 58ca7e3147..d16a8a7d32 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/soundex.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/soundex.md @@ -7,16 +7,17 @@ challengeType: 5 ## Description
Soundex is an algorithm for creating indices for words based on their pronunciation. -The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling (from the WP article). -There is a major issue in many of the implementations concerning the separation of two consonants that have the same soundex code! According to the official Rules https://www.archives.gov/research/census/soundex.html. So check for instance if Ashcraft is coded to A-261. - -Write a function that takes a string as a parameter and returns the encoded string. +The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling (from the WP article). +There is a major issue in many of the implementations concerning the separation of two consonants that have the same soundex code! According to the official Rules https://www.archives.gov/research/census/soundex.html. So check for instance if Ashcraft is coded to A-261. +
## Instructions
- +Write a function that takes a string as a parameter and returns the encoded string.
## Tests @@ -57,7 +58,7 @@ tests:
```js -function soundex (s) { +function soundex(s) { // Good luck! } ``` @@ -69,7 +70,7 @@ function soundex (s) {
```js -function soundex (s) { +function soundex(s) { var a = s.toLowerCase().split('') var f = a.shift(), r = '', diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/spiral-matrix.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/spiral-matrix.md index 8f85e187cc..a7cb721807 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/spiral-matrix.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/spiral-matrix.md @@ -30,8 +30,8 @@ For example, given 5, produce this array: tests: - text: spiralArray should be a function. testString: assert(typeof spiralArray=='function','spiralArray should be a function.'); - - text: spiralArray(3) should return a array. - testString: assert(Array.isArray(spiralArray(3)), 'spiralArray(3) should return a array.'); + - text: spiralArray(3) should return an array. + testString: assert(Array.isArray(spiralArray(3)), 'spiralArray(3) should return an array.'); - text: spiralArray(3) should return [[0, 1, 2],[7, 8, 3],[6, 5, 4]]. testString: assert.deepEqual(spiralArray(3), [[0, 1, 2], [7, 8, 3], [6, 5, 4]], 'spiralArray(3) should return [[0, 1, 2],[7, 8, 3],[6, 5, 4]].'); - text: spiralArray(4) should return [[0, 1, 2, 3],[11, 12, 13, 4],[10, 15, 14, 5],[9, 8, 7, 6]]. @@ -47,7 +47,7 @@ tests:
```js -function spiralArray (n) { +function spiralArray(n) { // Good luck! } ``` @@ -59,7 +59,7 @@ function spiralArray (n) {
```js -function spiralArray (n) { +function spiralArray(n) { var arr = Array(n), x = 0, y = n, total = n * n--, diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/split-a-character-string-based-on-change-of-character.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/split-a-character-string-based-on-change-of-character.md index 06874eaf9f..aacb6228a7 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/split-a-character-string-based-on-change-of-character.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/split-a-character-string-based-on-change-of-character.md @@ -9,9 +9,13 @@ challengeType: 5 Split a (character) string into comma (plus a blank) delimited strings based on a change of character (left to right). Blanks should be treated as any other character (except they are problematic to display clearly). The same applies to commas. For instance, the string: +
 "gHHH5YY++///\"
+
should be split as: -["g", "HHH", "5", "YY", "++", "///", "\" ] +
+["g", "HHH", "5", "YY", "++", "///", "\" ];
+
## Instructions @@ -26,8 +30,8 @@ should be split as: tests: - text: split should be a function. testString: assert(typeof split == 'function', 'split should be a function.'); - - text: split("hello") should return a array. - testString: assert(Array.isArray(split("hello")), 'split("hello") should return a array.'); + - text: split("hello") should return an array. + testString: assert(Array.isArray(split("hello")), 'split("hello") should return an array.'); - text: split("hello") should return ["h", "e", "ll", "o"]. testString: assert.deepEqual(split("hello"), ["h", "e", "ll", "o"], 'split("hello") should return ["h", "e", "ll", "o"].'); - text: split("commission") should return ["c", "o", "mm", "i", "ss", "i", "o", "n"]. @@ -47,7 +51,7 @@ tests:
```js -function split (str) { +function split(str) { // Good luck! } ``` @@ -59,7 +63,7 @@ function split (str) {
```js -function split (str) { +function split(str) { const concat = xs => xs.length > 0 ? (() => { const unit = typeof xs[0] === 'string' ? '' : []; diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/state-name-puzzle.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/state-name-puzzle.md index 601a235904..97b04c5716 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/state-name-puzzle.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/state-name-puzzle.md @@ -6,19 +6,16 @@ challengeType: 5 ## Description
-Background -This task is inspired by Mark Nelson's DDJ Column "Wordplay" and one of the weekly puzzle challenges from Will Shortz on NPR Weekend Edition [http://www.npr.org/templates/story/story.php?storyId=9264290] and originally attributed to David Edelheit. +This task is inspired by Mark Nelson's DDJ Column "Wordplay" and one of the weekly puzzle challenges from Will Shortz on NPR Weekend Edition [1] and originally attributed to David Edelheit. The challenge was to take the names of two U.S. States, mix them all together, then rearrange the letters to form the names of two different U.S. States (so that all four state names differ from one another). What states are these? -The problem was reissued on the Unicon Discussion Web which includes several solutions with analysis. Several techniques may be helpful and you may wish to refer to Gödel numbering, equivalence relations, and equivalence classes. The basic merits of these were discussed in the Unicon Discussion Web. +The problem was reissued on the Unicon Discussion Web which includes several solutions with analysis. Several techniques may be helpful and you may wish to refer to Gödel numbering, equivalence relations, and equivalence classes. The basic merits of these were discussed in the Unicon Discussion Web. A second challenge in the form of a set of fictitious new states was also presented. -Task: -Write a function to solve the challenge for the given array of names of states. The function should return an array. Each element should be an object in this form: {"from":[],"to":[]}. The "from" array should contain the original names and the "to" array should contain the resultant names.
## Instructions
- +Write a function to solve the challenge for the given array of names of states. The function should return an array. Each element should be an object in this form: {"from":[],"to":[]}. The "from" array should contain the original names and the "to" array should contain the resultant names.
## Tests @@ -28,8 +25,8 @@ Write a function to solve the challenge for the given array of names of states. tests: - text: solve should be a function. testString: assert(typeof solve == 'function', 'solve should be a function.'); - - text: solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return a array. - testString: assert(Array.isArray(solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"])), 'solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return a array.'); + - text: solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return an array. + testString: assert(Array.isArray(solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"])), 'solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return an array.'); - text: 'solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return [{ from: ["North Carolina ", "South Dakota"], to: ["North Dakota", "South Carolina"] }].' testString: assert.deepEqual(solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]), [{ from:["North Carolina ", "South Dakota"], to:["North Dakota", "South Carolina"] }], 'solve(["New Mexico", "New York", "North Carolina ", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota"]) should return [{ from:["North Carolina ", "South Dakota"], to:["North Dakota", "South Carolina"] }].'); - text: 'solve(["New York", "New Kory", "Wen Kory", "York New", "Kory New", "New Kory"]) should return [{ from: ["New Kory", "New York"], to: ["Wen Kory", "York New"] }, { from: ["New Kory", "New York"], to: ["Kory New", "Wen Kory"] }, { from: ["New Kory", "New York"], to: ["Kory New", "York New"] }, { from: ["New York", "Wen Kory"], to: ["New Kory", "York New"] }, { from: ["New York", "Wen Kory"], to: ["Kory New", "New Kory"] }, { from: ["New York", "Wen Kory"], to: ["Kory New", "York New"] }, { from: ["New York", "York New"], to: ["New Kory", "Wen Kory"] }, { from: ["New York", "York New"], to: ["Kory New", "New Kory"] }, { from: ["New York", "York New"], to: ["Kory New", "Wen Kory"] }, { from: ["Kory New", "New York"], to: ["New Kory", "Wen Kory"] }, { from: ["Kory New", "New York"], to: ["New Kory", "York New"] }, { from: ["Kory New", "New York"], to: ["Wen Kory", "York New"] }, { from: ["New Kory", "Wen Kory"], to: ["Kory New", "York New"] }, { from: ["New Kory", "York New"], to: ["Kory New", "Wen Kory"] }, { from: ["Kory New", "New Kory"], to: ["Wen Kory", "York New"] }].' @@ -43,7 +40,7 @@ tests:
```js -function solve (input) { +function solve(input) { // Good luck! } ``` @@ -55,7 +52,7 @@ function solve (input) {
```js -function solve (input) { +function solve(input) { var orig = {}; input.forEach(function(e) { orig[e.replace(/\s/g, "").toLowerCase()] = e;