Skip to content

Commit

Permalink
Add q24
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Jul 23, 2024
1 parent cbb6f44 commit bb8f396
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ex/q024.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; https://4clojure.oxal.org/#/problem/024

(ns ex.q024)

(defn ans
"Problem 24, Sum It All Up"
[coll]
(reduce + 0 coll))
13 changes: 13 additions & 0 deletions test/ex/q024_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;; https://4clojure.oxal.org/#/problem/024

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

(t/deftest test-q24
(t/testing "Problem 24, Sum It All Up"
(t/is (= 6 (sut/ans [1 2 3])))
(t/is (= 8 (sut/ans (list 0 -2 5 5))))
(t/is (= 7 (sut/ans #{4 2 1})))
(t/is (= -1 (sut/ans '(0 0 -1))))
(t/is (= 14 (sut/ans '(1 10 3))))))

0 comments on commit bb8f396

Please sign in to comment.