As they often say how computer algorithms are similar to culinary recipes, I decided to write this recipe in Pythonic dialect of English. You should have no trouble understanding it.
from random import random # random def make_pudding(pudding_type='vanilla', K=1): """ Returns pudding of type `pudding_type` and in quantity `K`. Parameters ---------- pudding_type: str The type/flavor of your pudding. One of: 'vanilla', 'chocolate', 'fruit_jello'. K: float Quantity scalar coefficient. """ # # Ingredients: # eggs = egg(round(1 * K)) sugar = sugar(spoonful(2 * K)) flour = flour(spoonful(5 * K)) liquid_type = kompot if pudding_type == 'fruit_jello' else milk liquid = liquid_type(liters(0.5 * K)) if pudding_type == 'chocolate': chocolate = ground_chocolate(spoonful(5 * K)) pieces_of_fruit = pieces_of_fruit(30 * K * (random() > 0.5)) # # Recipe: # mix_1 = 0.1 * liquid + flour if pudding_type == 'chocolate': mix_1 += chocolate mix_2 = eggs + sugar mix = 0.9 * liquid + cinnamon() + salt() + vanilla_extract() bring_to_boil(mix) mix += mix_1 bring_to_boil(mix) mix += mix_2 bring_to_boil(mix) mix += pieces_of_fruit pudding = mix return puddingSo you can read computer programs?
Usage is as easy as
make_pudding('chocolate'), but the code is relatively new and untested. If you spot any bugs or have ideas for enhancements, please do report them.
You can't go wrong. Enjoy. ;-)