Created
April 17, 2014 20:28
-
-
Save cmaggard/11009625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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