* 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.4 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
af2170cad53daa0770fabdea | 比较字符串 | 5 | 16025 | mutations |
--description--
输入参数是一个数组,其中包含两个字符串元素。如果数组里的第一个字符串包含了第二个字符串中的所有字母,则返回 true。
例如,["hello", "Hello"]
应该返回 true。因为在忽略大小写的情况下,第一个字符串中包含了第二个字符串里出现的所有字母。
而 ["hello", "hey"]
应该返回 false。因为第一个字符串 "hello" 没有包含字母 "y"。
最后,["Alien", "line"]
应该返回 true。因为 "line" 中的所有字母都出现在了 "Alien" 中。
--hints--
mutation(["hello", "hey"])
应返回 false。
assert(mutation(['hello', 'hey']) === false);
mutation(["hello", "Hello"])
应返回 true。
assert(mutation(['hello', 'Hello']) === true);
mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])
应返回 true。
assert(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu']) === true);
mutation(["Mary", "Army"])
应返回 true。
assert(mutation(['Mary', 'Army']) === true);
mutation(["Mary", "Aarmy"])
应返回 true。
assert(mutation(['Mary', 'Aarmy']) === true);
mutation(["Alien", "line"])
应返回 true。
assert(mutation(['Alien', 'line']) === true);
mutation(["floor", "for"])
应返回 true。
assert(mutation(['floor', 'for']) === true);
mutation(["hello", "neo"])
应返回 false。
assert(mutation(['hello', 'neo']) === false);
mutation(["voodoo", "no"])
应返回 false。
assert(mutation(['voodoo', 'no']) === false);
mutation(["voodoo", "no"])
应返回 false。
assert(mutation(['voodoo', 'no']) === false);
mutation(["ate", "date"]
应返回 false。
assert(mutation(['ate', 'date']) === false);
mutation(["Tiger", "Zebra"])
应返回 false。
assert(mutation(['Tiger', 'Zebra']) === false);
mutation(["Noel", "Ole"])
应返回 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"]);