Skip to content

Instantly share code, notes, and snippets.

@jacobstanley
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save jacobstanley/d7108dd60c4af73d2a51 to your computer and use it in GitHub Desktop.

Select an option

Save jacobstanley/d7108dd60c4af73d2a51 to your computer and use it in GitHub Desktop.
-- Solve for the maximum/minimum number of menu items adding up to $15.05
-- http://xkcd.com/287/
xkcd :: Direction -> Program String String IntDouble
xkcd dir = program dir
( z1 mf .+.
z1 ff .+.
z1 ss .+.
z1 hw .+.
z1 ms .+.
z1 sp )
( z mf mfp .+.
z ff ffp .+.
z ss ssp .+.
z hw hwp .+.
z ms msp .+.
z sp spp :== con 1505 )
[ lowerZ 0 mf
, lowerZ 0 ff
, lowerZ 0 ss
, lowerZ 0 hw
, lowerZ 0 ms
, lowerZ 0 sp
]
where
(mf, mfp) = ("mixed-fruit", 215)
(ff, ffp) = ("french-fries", 275)
(ss, ssp) = ("side-salad", 335)
(hw, hwp) = ("hot-wings", 355)
(ms, msp) = ("mozzarella-sticks", 420)
(sp, spp) = ("sampler-plate", 580)
@jacobstanley

Copy link
Copy Markdown
Author

General solutions get you a 50% tip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment