Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbale committed Aug 20, 2011
0 parents commit d44b82b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/vending_machine/vm.clj
@@ -0,0 +1,27 @@
(ns vending-machine.vm)

(def NICKEL 5)
(def DIME 10)
(def QUARTER 25)

(defn coin-return [] (list NICKEL DIME))

(defn purchase [purchase-price, deposits, coin-return]
"Indicate true/false if purchase succeeded, given the int (cents) purchase
price, sequence of deposited coins, and sequence of available coin return
coins."

(cond (sufficient-funds purchase-price deposits)
{:success true :change (change-due purchase-price deposits) :reserve deposits}
:else {:success false}
))

(defn sufficient-funds [purchase-price, coins]
(<= purchase-price (reduce + coins)))

(defn change-due [purchase-price, coins]
(- (reduce + coins) purchase-price))

(defn make-change [change-due, coins]
0
)

0 comments on commit d44b82b

Please sign in to comment.