diff --git a/otus-02/src/otus_02/homework/palindrome.clj b/otus-02/src/otus_02/homework/palindrome.clj index dd3d8a4..5b902c3 100644 --- a/otus-02/src/otus_02/homework/palindrome.clj +++ b/otus-02/src/otus_02/homework/palindrome.clj @@ -1,4 +1,15 @@ -(ns otus-02.homework.palindrome) +(ns otus-02.homework.palindrome + (:require [clojure.string :as cs])) +(defn- bad-char? [c] + (boolean (some #{\space \? \,} [c]))) -(defn is-palindrome [test-string]) +(defn- bad-char-to-nil [c] + (when-not (bad-char? c) + c)) +(defn- rm-bad-chars [s] + (apply str (map bad-char-to-nil s))) +(defn is-palindrome [test-string] + (let [s (cs/lower-case (rm-bad-chars test-string)) + rs (cs/reverse s)] + (= s rs))) \ No newline at end of file