Skip to content

Commit

Permalink
Add q49
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkun committed Aug 17, 2024
1 parent 62951fe commit 9d97b47
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ex/q049.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;; https://4clojure.oxal.org/#/problem/049

(ns ex.q049)

(defn ans
"Problem 49, Split a sequence. restriction: split-at"
[n coll]
[(take n coll) (drop n coll)])
11 changes: 11 additions & 0 deletions test/ex/q049_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;; https://4clojure.oxal.org/#/problem/049

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

(t/deftest test-q49
(t/testing "Problem 49, Split a sequence"
(t/is (= [[1 2 3] [4 5 6]] (sut/ans 3 [1 2 3 4 5 6])))
(t/is (= [[:a] [:b :c :d]] (sut/ans 1 [:a :b :c :d])))
(t/is (= [[[1 2] [3 4]] [[5 6]]] (sut/ans 2 [[1 2] [3 4] [5 6]])))))

0 comments on commit 9d97b47

Please sign in to comment.