* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2.3 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
af2170cad53daa0770fabdea | Mutations | 5 | 16025 | mutations |
--description--
Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
For example, ["hello", "Hello"]
, should return true because all of the letters in the second string are present in the first, ignoring case.
The arguments ["hello", "hey"]
should return false because the string "hello" does not contain a "y".
Lastly, ["Alien", "line"]
, should return true because all of the letters in "line" are present in "Alien".
--hints--
mutation(["hello", "hey"])
should return false.
assert(mutation(['hello', 'hey']) === false);
mutation(["hello", "Hello"])
should return true.
assert(mutation(['hello', 'Hello']) === true);
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])
should return true.
assert(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']) === true);
mutation(["Mary", "Army"])
should return true.
assert(mutation(['Mary', 'Army']) === true);
mutation(["Mary", "Aarmy"])
should return true.
assert(mutation(['Mary', 'Aarmy']) === true);
mutation(["Alien", "line"])
should return true.
assert(mutation(['Alien', 'line']) === true);
mutation(["floor", "for"])
should return true.
assert(mutation(['floor', 'for']) === true);
mutation(["hello", "neo"])
should return false.
assert(mutation(['hello', 'neo']) === false);
mutation(["voodoo", "no"])
should return false.
assert(mutation(['voodoo', 'no']) === false);
mutation(["ate", "date"]
should return false.
assert(mutation(['ate', 'date']) === false);
mutation(["Tiger", "Zebra"])
should return false.
assert(mutation(['Tiger', 'Zebra']) === false);
mutation(["Noel", "Ole"])
should return true.
assert(mutation(['Noel', 'Ole']) === true);
--seed--
--seed-contents--
function mutation(arr) {
return arr;
}
mutation(["hello", "hey"]);
--solutions--
function mutation(arr) {
let hash = Object.create(null);
arr[0].toLowerCase().split('').forEach(c => hash[c] = true);
return !arr[1].toLowerCase().split('').filter(c => !hash[c]).length;
}
mutation(["hello", "hey"]);