From bd0335d5cb4b651a898a4c688a7bf273d95d1e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?leos=D1=81hulmann?= Date: Tue, 9 May 2023 23:02:58 +0300 Subject: [PATCH] solution --- otus-02/src/otus_02/homework/palindrome.clj | 8 +++++--- otus-02/src/otus_02/homework/pangram.clj | 10 +++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/otus-02/src/otus_02/homework/palindrome.clj b/otus-02/src/otus_02/homework/palindrome.clj index dd3d8a4..a879e59 100644 --- a/otus-02/src/otus_02/homework/palindrome.clj +++ b/otus-02/src/otus_02/homework/palindrome.clj @@ -1,4 +1,6 @@ -(ns otus-02.homework.palindrome) +(ns otus-02.homework.palindrome + (:require [clojure.string :as str])) - -(defn is-palindrome [test-string]) +(defn is-palindrome [test-string] + (let [prepared-str (str/lower-case (str/replace test-string #"\W" ""))] + (= prepared-str (str/reverse prepared-str)))) diff --git a/otus-02/src/otus_02/homework/pangram.clj b/otus-02/src/otus_02/homework/pangram.clj index cc35c99..f520e87 100644 --- a/otus-02/src/otus_02/homework/pangram.clj +++ b/otus-02/src/otus_02/homework/pangram.clj @@ -1,4 +1,8 @@ -(ns otus-02.homework.pangram) +(ns otus-02.homework.pangram + (:require [clojure.string :as str])) - -(defn is-pangram [test-string]) +(defn is-pangram [test-string] + (let [alphabet (vec "abcdefghijklmnopqrstuvwxyz")] + (= alphabet + (sort (distinct + (str/lower-case (str/replace test-string #"\W" "")))))))