Skip to content

Commit

Permalink
Fix partiphify solution (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
solar05 authored Dec 4, 2023
1 parent 4a76bef commit 8bc8fbf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/battle_asserts/issues/partiphify.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
(gen/tuple (gen/vector gen/small-integer 2 10) (gen/choose 2 4)))

(def test-data
[{:expected [[1] []] :arguments [[1] 2]}
[{:expected [[1]] :arguments [[1] 2]}
{:expected [[1] [2] [3]] :arguments [[1 2 3] 3]}
{:expected [[1 2 3] [4 5]] :arguments [[1 2 3 4 5] 2]}])

(defn solution [numbers parts]
(let [part (int (Math/ceil (/ (count numbers) parts)))
divided-vec (vec (map vec (partition-all part numbers)))
final-vec (if (not= (count divided-vec) parts) (conj divided-vec []) divided-vec)]
final-vec (filterv seq divided-vec)]
final-vec))

0 comments on commit 8bc8fbf

Please sign in to comment.