首页 > 代码库 > [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]
(fn [s]
(set (map set (filter #(> (count %) 1) (vals (group-by frequencies s))))))
(group-by 非常强大)
[4Clojure]解题记录-#77
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。