Skip to content

Instantly share code, notes, and snippets.

@naush
Last active December 12, 2015 09:19
Show Gist options
  • Save naush/4750910 to your computer and use it in GitHub Desktop.
Save naush/4750910 to your computer and use it in GitHub Desktop.
-- http://xkcd.com/287/
import Data.List
order menu amount items
| amount < 0 = []
| amount == 0 = [items]
| otherwise = foldl (\meals (item, price) ->
meals ++ order menu (amount - price) (item : items)) [] menu
menu = [("Mixed Fruit", 215), ("French Fries", 275), ("Side Salad", 335), ("Hot Wings", 355), ("Mozzarella Sticks", 420), ("Sampler Plate", 580)]
main = print (nub (map sort (order menu 1505 [])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment