Skip to content

Commit

Permalink
Add q27
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Jul 25, 2024
1 parent 164e681 commit 3e0c72f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ex/q027.clj
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions test/ex/q027_test.clj
Original file line number Diff line number Diff line change
@@ -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))))))

0 comments on commit 3e0c72f

Please sign in to comment.