Files
2022-01-20 20:30:18 +01:00

2.8 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
af2170cad53daa0770fabdea ミューテーション 5 16025 mutations

--description--

配列の最初の要素内の文字列に、2 番目の要素内の文字列にあるすべての文字が含まれている場合に、true を返してください。

たとえば、["hello", "Hello"] は、2 番目の文字列内のすべての文字が最初の文字列に含まれているので、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(["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"]);