Sha256: e0246a6ef0ebd27506dc9984a45ecaa3597c08ec90a8345fddc6f14615c420c0
Contents?: true
Size: 608 Bytes
Versions: 10
Compression:
Stored size: 608 Bytes
Contents
let stringToCharArray = (s) => { let len = String.length(s); Array.init(len, n => s.[n]); } let isAnagram = (base, word) => { if(String.length(base) != String.length(word)) { false } else { let base = String.lowercase(base); let word = String.lowercase(word); if(base == word) { false } else { let base = stringToCharArray(base); Array.sort(Char.compare, base); let word = stringToCharArray(word); Array.sort(Char.compare, word); base == word; } } }; let anagrams = (base, candidates) => { List.filter(isAnagram(base), candidates); };
Version data entries
10 entries across 10 versions & 1 rubygems