Skip to content

Instantly share code, notes, and snippets.

@naush
Last active December 12, 2015 09:19
Show Gist options
  • Save naush/4750581 to your computer and use it in GitHub Desktop.
Save naush/4750581 to your computer and use it in GitHub Desktop.
;; 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