From 3e0c72fd4d1ff4e69caa33f1487bd4047a657779 Mon Sep 17 00:00:00 2001 From: David Kun Date: Thu, 25 Jul 2024 08:05:27 -0400 Subject: [PATCH] Add q27 --- src/ex/q027.clj | 8 ++++++++ test/ex/q027_test.clj | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/ex/q027.clj create mode 100644 test/ex/q027_test.clj diff --git a/src/ex/q027.clj b/src/ex/q027.clj new file mode 100644 index 0000000..0025ca4 --- /dev/null +++ b/src/ex/q027.clj @@ -0,0 +1,8 @@ +;; https://4clojure.oxal.org/#/problem/027 + +(ns ex.q027) + +(defn ans + "Problem 27, Palindrome Detector" + [coll] + (= (seq coll) (reverse coll))) ;; O(n) time, but concise \ No newline at end of file diff --git a/test/ex/q027_test.clj b/test/ex/q027_test.clj new file mode 100644 index 0000000..0269272 --- /dev/null +++ b/test/ex/q027_test.clj @@ -0,0 +1,13 @@ +;; https://4clojure.oxal.org/#/problem/027 + +(ns ex.q027-test + (:require [clojure.test :as t] + [ex.q027 :as sut])) + +(t/deftest test-q27 + (t/testing "Problem 27, Palindrome Detector" + (t/is (false? (sut/ans '(1 2 3 4 5)))) + (t/is (true? (sut/ans "racecar"))) + (t/is (true? (sut/ans [:foo :bar :foo]))) + (t/is (true? (sut/ans '(1 1 3 3 1 1)))) + (t/is (false? (sut/ans '(:a :b :c)))))) \ No newline at end of file