diff --git a/curriculum/challenges/english/25-front-end-development/lab-permutation-generator/66fe4f33a2cc9b33f4d5cd9b.md b/curriculum/challenges/english/25-front-end-development/lab-permutation-generator/66fe4f33a2cc9b33f4d5cd9b.md index d20d49d8f16..65b93b9da28 100644 --- a/curriculum/challenges/english/25-front-end-development/lab-permutation-generator/66fe4f33a2cc9b33f4d5cd9b.md +++ b/curriculum/challenges/english/25-front-end-development/lab-permutation-generator/66fe4f33a2cc9b33f4d5cd9b.md @@ -7,9 +7,9 @@ dashedName: build-a-permutation-generator # --description-- -In this lab, you will build a permutation generator that will take a string and return all possible permutations of the characters in the string. For example, the possible permutations of the string `'cat'` are `'cat'`, `'cta'`, `'act'`, `'atc'`, `'tac'`, and `'tca'`. +In this lab, you will build a permutation generator that will take a string and return all possible permutations of the characters in the string. For example, the possible permutations of the string `cat` are `cat`, `cta`, `act`, `atc`, `tac`, and `tca`. -**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab. +**Objective:** Fulfill the user stories below and get all the tests to pass to complete the lab. **User Stories:** @@ -34,100 +34,100 @@ You should use recursion in your `permuteString` function. assert.match(permuteString.toString(), /permuteString\s*\(/); ``` -`permuteString('far')` should return `[ 'far', 'fra', 'afr', 'arf', 'rfa', 'raf' ]`. +`permuteString("far")` should return `[ "far", "fra", "afr", "arf", "rfa", "raf" ]`. ```js -assert.sameMembers(permuteString('far'), [ 'far', 'fra', 'afr', 'arf', 'rfa', 'raf' ]); +assert.sameMembers(permuteString("far"), [ "far", "fra", "afr", "arf", "rfa", "raf" ]); ``` -`permuteString('fcc')` should return `[ 'fcc', 'cfc', 'ccf' ]`. +`permuteString("fcc")` should return `[ "fcc", "cfc", "ccf" ]`. ```js -assert.sameMembers(permuteString('fcc'), [ 'fcc', 'cfc', 'ccf' ]); +assert.sameMembers(permuteString("fcc"), [ "fcc", "cfc", "ccf" ]); ``` -`permuteString('p')` should return `[ 'p' ]`. +`permuteString("p")` should return `[ "p" ]`. ```js -assert.deepStrictEqual(permuteString('p'), ['p']); +assert.deepStrictEqual(permuteString("p"), ["p"]); ``` -`permuteString('')` should return `['']`. +`permuteString("")` should return `[""]`. ```js -let emptyArr= permuteString(''); +let emptyArr= permuteString(""); // 1 because the empty string is being pushed and is a permutation of itself -assert.lengthOf(emptyArr, 1); +assert.lengthOf(emptyArr, 1); ``` -`permuteString('101')` should return `[ '101', '011', '110' ]`. +`permuteString("101")` should return `[ "101", "011", "110" ]`. ```js -assert.sameMembers(permuteString('101'), [ '101', '011', '110']); +assert.sameMembers(permuteString("101"), [ "101", "011", "110"]); ``` `permuteString` should return the correct results. ```js // tests to prevent hard coding -assert.sameMembers(permuteString('road'), [ 'road', - 'roda', - 'raod', - 'rado', - 'rdoa', - 'rdao', - 'orad', - 'orda', - 'oard', - 'oadr', - 'odra', - 'odar', - 'arod', - 'ardo', - 'aord', - 'aodr', - 'adro', - 'ador', - 'droa', - 'drao', - 'dora', - 'doar', - 'daro', - 'daor' ]); +assert.sameMembers(permuteString("road"), [ "road", + "roda", + "raod", + "rado", + "rdoa", + "rdao", + "orad", + "orda", + "oard", + "oadr", + "odra", + "odar", + "arod", + "ardo", + "aord", + "aodr", + "adro", + "ador", + "droa", + "drao", + "dora", + "doar", + "daro", + "daor" ]); -assert.sameMembers(permuteString('fog'), [ 'fog', - 'fgo', - 'ofg', - 'ogf', - 'gfo', - 'gof' ]); +assert.sameMembers(permuteString("fog"), [ "fog", + "fgo", + "ofg", + "ogf", + "gfo", + "gof" ]); -assert.sameMembers(permuteString('bird'), [ 'bird', - 'bidr', - 'brid', - 'brdi', - 'bdir', - 'bdri', - 'ibrd', - 'ibdr', - 'irbd', - 'irdb', - 'idbr', - 'idrb', - 'rbid', - 'rbdi', - 'ribd', - 'ridb', - 'rdbi', - 'rdib', - 'dbir', - 'dbri', - 'dibr', - 'dirb', - 'drbi', - 'drib' ]); +assert.sameMembers(permuteString("bird"), [ "bird", + "bidr", + "brid", + "brdi", + "bdir", + "bdri", + "ibrd", + "ibdr", + "irbd", + "irdb", + "idbr", + "idrb", + "rbid", + "rbdi", + "ribd", + "ridb", + "rdbi", + "rdib", + "dbir", + "dbri", + "dibr", + "dirb", + "drbi", + "drib" ]); ``` @@ -142,14 +142,14 @@ assert.sameMembers(permuteString('bird'), [ 'bird', # --solutions-- ```js -const permuteString = (str, prefix = '', result = []) => { +const permuteString = (str, prefix = "", result = []) => { if (str.length === 0) { result.push(prefix); return result; } // Sort the string initially to group duplicates - const sortedStr = str.split('').sort().join(''); + const sortedStr = str.split("").sort().join(""); for (let i = 0; i < sortedStr.length; i++) { if (i > 0 && sortedStr[i] === sortedStr[i - 1]) {