Skip to content

Instantly share code, notes, and snippets.

@joshrotenberg
Created June 25, 2019 13:11
Show Gist options
  • Save joshrotenberg/25aebc2128f06fa76820e275301b695e to your computer and use it in GitHub Desktop.
Save joshrotenberg/25aebc2128f06fa76820e275301b695e to your computer and use it in GitHub Desktop.
(def input [[1 2 3] [4 5 6] [9 8 9]])
(defn diag-diff2
[arr]
(->> arr
(map-indexed (fn [i e] [(nth e i) (nth e (- (count arr) i 1))]))
(reduce (fn [acc [x y]] [(+ (first acc) x) (+ (second acc) y)]))
(reduce -)
Math/abs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment