Travis build: 1705 [cron]

This commit is contained in:
30secondsofcode
2018-02-19 20:25:25 +00:00
parent d0f1901ada
commit 409e83d593
8 changed files with 2036 additions and 1864 deletions

View File

@ -1,5 +1,11 @@
const isAnagram = (str1, str2) => {
const normalize = str => str.toLowerCase().replace(/[^a-z0-9]/gi, '').split('').sort().join('');
const normalize = str =>
str
.toLowerCase()
.replace(/[^a-z0-9]/gi, '')
.split('')
.sort()
.join('');
return normalize(str1) === normalize(str2);
};
module.exports = isAnagram;
module.exports = isAnagram;

View File

@ -3,10 +3,7 @@ if (arr.length <= 2) return arr.length === 2 ? [arr, [arr[1], arr[0]]] : arr;
return arr.reduce(
(acc, item, i) =>
acc.concat(
permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [
item,
...val,
])
permutations([...arr.slice(0, i), ...arr.slice(i + 1)]).map(val => [item, ...val])
),
[]
);

File diff suppressed because it is too large Load Diff