Created
March 5, 2012 16:03
-
-
Save bodil/1979023 to your computer and use it in GitHub Desktop.
Anagram-kata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns ohai | |
(:use clojure.test)) | |
(def words | |
'("foo" | |
"rab" | |
"rba")) | |
(with-test | |
(defn anagram? [a b] | |
(= (sort a) (sort b))) | |
(is (anagram? "foo" "oof")) | |
(is (anagram? "bar" "rba")) | |
(is (false? (anagram? "foo" "bar")))) | |
(with-test | |
(defn anagrams [word] | |
(filter #(anagram? % word) words)) | |
(is (= () (anagrams "blerk"))) | |
(is (= '("foo") (anagrams "foo"))) | |
(is (= '("foo") (anagrams "oof"))) | |
(is (= '("rab" "rba") (anagrams "bar"))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment