Skip to content

Commit

Permalink
Merge pull request #223 from MrPhantomT/feature/fix_integer_difference
Browse files Browse the repository at this point in the history
fix solution integer difference
  • Loading branch information
mokevnin committed Oct 27, 2015
2 parents ab22959 + 2a5972e commit 094f8be
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 094f8be

Please sign in to comment.