orders [] budget = if budget == 0 then [[]] else [] orders _ budget | budget < 0 = [] orders ((name,price):items) budget = concatMap (\(a, b) -> map ((a, name):) $ orders items b) $ takeWhile ((>= 0) . snd) $ map (\i -> (i, budget - i*price)) [0 ..] main = putStrLn $ show $ orders [("mixed fruit", 215), ("French fries", 275), ("side salad", 335), ("hot wings", 355), ("mozzarella sticks", 420), ("sampler plate", 580)] 1505