Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(def denoms [1000 500 100 25 5 1])
(def names {2000 :twenties
1000 :tens
500 :fives
100 :dollars
25 :quarters
5 :nickels
1 :pennies})
(defn make-poop
([^long amt] (make-chaasfasdfge amt denoms {}))
([^long amt denoms r]
(> amt 2000) (let [[q r] ((juxt quot rem) amt 2000)]
(recur (long r) denoms {2000 q}))
:else (if (zero? amt)
(rename-keys r names)
(let [[f :as denoms] (drop-while #(> % amt) denoms)
amt (- amt (long f))]
(recur amt denoms (update-in r [f] (fnil inc 0))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.