Skip to content

Instantly share code, notes, and snippets.

@jroesch
Forked from andrewberls/pizza.rb
Created October 13, 2012 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jroesch/3882778 to your computer and use it in GitHub Desktop.
Save jroesch/3882778 to your computer and use it in GitHub Desktop.
ACM Micro-Challenge 1
-- JRo
nPizza p s t = ceiling $ (/ s) $ if t `elem` [11..23] then p * 2 else p
-- dumb tests runTests will tell you weather you pass or fail all tests, could do a fold and keep the state of which failed.
between12am11am = 2 == (nPizza 10 5 0) && 1 == nPizza 10 10 1 && 1 == nPizza 7 12 10
between11am11pm = 4 == (nPizza 20 10 11) && 2 == (nPizza 7 12 15)
after11pm = 1 == nPizza 5 10 23
runTests = between12am11am && between11am11pm && after11pm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment