Skip to content

Instantly share code, notes, and snippets.

@cmaggard
Created April 17, 2014 20:28
Show Gist options
  • Save cmaggard/11009625 to your computer and use it in GitHub Desktop.
Save cmaggard/11009625 to your computer and use it in GitHub Desktop.
(ns diablo)
(defn craft-cost [x]
(cond
(> x 0) (* 100000 (+ 1 x))
:default 0))
(defn gem-cost [level]
(reduce +
(map
#(*
(int (Math/pow 3 (- level %)))
(craft-cost %))
(range (+ 1 level)))))
;(println (map #(gem-cost %) (range 5)))
;(0 200000 900000 3100000 9800000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment