首页 > 代码库 > [4Clojure]解题记录-#77

[4Clojure]解题记录-#77

Anagram Finder
 

Difficulty:Medium
Topics: 
 
Write a function which finds all the anagrams in a vector of words. A word x is an anagram of word y if all the letters in x can be rearranged in a different order to form y. Your function should return a set of sets, where each sub-set is a group of words which are anagrams of each other. Each sub-set should have at least two words. Words without any anagrams should not be included in the result.
(找出输入集合的所有符合条件的子集,这个条件是,子集中的单词都是有相同的字母通过不同方式排列组合而成)
 
(= (__ ["meat" "mat" "team" "mate" "eat"])  #{#{"meat" "team" "mate"}})
 
(= (__ ["veer" "lake" "item" "kale" "mite" "ever"]) #{#{"veer" "ever"} #{"lake" "kale"} #{"mite" "item"}})
 
解长度:69
(fn [s] 
   (set (map set (filter #(> (count %) 1) (vals (group-by frequencies s))))))
(group-by 非常强大)

[4Clojure]解题记录-#77