Skip to content

Commit

Permalink
fix solution integer difference
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Dementev committed Oct 27, 2015
1 parent 5f756c8 commit 2a5972e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/battle_asserts/issues/integer_difference.clj
Expand Up @@ -19,17 +19,24 @@
[{:expected 3
:arguments [4 [1 1 5 6 9 16 27]]}
{:expected 4
:arguments [2 [1 1 3 3]]}])
:arguments [2 [1 1 3 3]]}
{:expected 3
:arguments [12 [6 6 2 -11 9 -3 9 12 0 -11 7]]}
{:expected 3
:arguments [7 [1 5 -2 2 -5 7 -2]]}
{:expected 2
:arguments [1 [-1 1 0]]}
{:expected 4
:arguments [3 [-2 0 -2 3 3 1]]}])

(defn solution [differ, nums]
(defn solution [differ nums]
(->>
nums
(reduce-kv #(let [next-elements (drop (inc %2) nums)]
(concat %1 (pmap vector
next-elements
(repeat (count next-elements) %3))))
(concat %1 (map vector
(cycle [%3])
next-elements)))
[])
(pmap #(- (first %)
(second %)))
(map #(Math/abs (apply - %)))
(filter #(= differ %))
count))

0 comments on commit 2a5972e

Please sign in to comment.