Skip to content

Commit

Permalink
Add q29
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Jul 29, 2024
1 parent 9e9cd6d commit 80fa577
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ex/q029.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
;; https://4clojure.oxal.org/#/problem/029

(ns ex.q029)

(defn ans
"Problem 29, Get the Caps. (return a new string containing only the capital letters)"
[s]
(let [caps (set "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]
(apply str (filter #(contains? caps %) s))))
11 changes: 11 additions & 0 deletions test/ex/q029_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;; https://4clojure.oxal.org/#/problem/029

(ns ex.q029-test
(:require [clojure.test :as t]
[ex.q029 :as sut]))

(t/deftest test-q29
(t/testing "Problem 29, Get the Caps"
(t/is (= "HLOWRD" (sut/ans "HeLlO, WoRlD!")))
(t/is (empty? (sut/ans "nothing")))
(t/is (= "AZ" (sut/ans "$#A(*&987Zf")))))

0 comments on commit 80fa577

Please sign in to comment.