Last active
December 12, 2015 09:19
-
-
Save naush/4750581 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ;; http://xkcd.com/287/ | |
| (defn order [menu amount items] | |
| (cond | |
| (< amount 0) [] | |
| (= amount 0) [items] | |
| :else (reduce | |
| (fn [meals, [item price]] | |
| (concat meals (order menu (- amount price) (into [item] items)))) [] menu))) | |
| (def menu {:mixed_fruit 215, :french_fries 275, :side_salad 335, :hot_wings 355, :mozzarella_sticks 420, :sampler_plate 580}) | |
| (distinct (map #(sort-by str %) (order menu 1505 []))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment