Last active
December 29, 2015 02:18
-
-
Save rowanseymour/7599049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generates an order of lunch | |
* @param people the number of people | |
* @param whether or not dessert is desired | |
*/ | |
function generateOrder(people, dessert) { | |
var soups = Math.floor(Math.max(people / 5, 1)); | |
var plates = people; // ? | |
var perDish = function(peeps) { | |
if (plates > 0) { | |
var dishesOf = Math.min(Math.floor(Math.max(people / peeps, 1)), plates); | |
plates -= dishesOf; | |
return dishesOf; | |
} | |
return 0; | |
}; | |
var order = new Object(); | |
var orderDish = function(name, number) { | |
if (number > 0) { | |
order[name] = number; | |
} | |
}; | |
orderDish('3DI Soup (A1)', soups); | |
orderDish('Rice (?)', perDish(5)); | |
orderDish('Sweet & Sour (?)', dessert ? perDish(5) : 0); | |
orderDish('Chilli Chicken (C12)', perDish(3)); | |
orderDish('Noodles w/ Beef (B8)', perDish(6)); | |
orderDish('Curry Beef (E5)', perDish(5)); | |
orderDish('Chicken w/ Corn (C7)', perDish(5)); | |
return order; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I really feel this needs some random element to it. There should be a few surprise dishes that occasionally get added to the mix. Desert should be one of them. You don't get to decide when it wills itself upon you.