Skip to content

Instantly share code, notes, and snippets.

Created Dec 12, 2016
What would you like to do?
// Sort the strings alphabetically, then sort the strings by length
// Naively compare each string to the others and try to find anagrams.
function hasAnagram(strings) {
const sorted = => s.split("").sort().join("")).sort();
return sorted.some((s, i) => {
const sliced = sorted.slice(0, i).concat(sorted.slice(i+1));
return sliced.find(s2 => s == s2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment