You are a talented young chef who has just been offered the position of sous chef at the world's most prestigious Indian restaurant. You have little experience with preparing Indian cuisine, but you're determined, so you set out to prove yourself. You decide to become the leading dosa expert. To do this, you must not only master the creation of dosas, but you must be able to scale them to be arbitrarily large.
You find a promising recipe for dosa batter:
- 1 cup rice
- 1 cup ukda chawal
- 1/2 cup urad dal
- 1/4 cup poha
- 1/4 tsp methi seeds
- Salt to taste
- Water as needed
This will make a dosa approximately 1/2 meter in length.
Write a program or function that will tell the restaurant staff exactly what's needed to make a single dosa out of an integer multiple of the given recipe. Space is tight in the kitchen, so you want your code to be as short as possible. The shortest code wins, with ties going to the earlier post.
Measuring spoons and cups come in the following standard sizes: 1/4, 1/3, 1/2, 2/3, 3/4, and 1. To avoid angering the kitchen staff, measurements must be reported in the largest unit in which the number can be written as mixed numbers using standard sizes only.
Measurements propagate to larger sizes per the following convention:
- 3 tsp == 1 tbsp
- 4 tbsp == 1/4 cup
So for a multiple of 12, 1/4 tsp methi seeds becomes 1 tbsp. However, for a multiple of 13, it becomes 3 1/4 tsp. Otherwise it wouldn't be represented in standard sizes.
The wait staff must be able to carry the dosa to the tables. To ensure that the dosa does not break in transit, you instruct them to carry the dosa in teams. Each person can carry at most one meter of dosa. So for a single or double recipe, only one person is needed to carry it. The wait staff is less effective if they're cut into fractional pieces, so an integer number of waiters is always required.
Take a positive integer via STDIN (or closest alternative), command line argument, or function argument. This number dictates the scaling factor for the recipe and can be as small as 1 but no larger than 232-1. It can be any integer in that range.
Print to STDOUT (or closest alternative) the list of ingredients scaled according to the input as well as the number of waiters required to carry the dosa. The ingredients must be listed in the order given above and in the format given below.
2 cups rice 2 cups ukda chawal 1 cup urad dal 1/2 cup poha 1/2 tsp methi seeds Salt to taste Water as needed 1 waiter
Note that "cup" changes to "cups" when the value is greater than 1. "tsp" does not change. "waiter," like "cup," becomes plural.
5 cups rice 5 cups ukda chawal 2 1/2 cups urad dal 1 1/4 cups poha 1 1/4 tsp methi seeds Salt to taste Water as needed 3 waiters
Non-integer values greater than 1 are represented as mixed numbers, i.e. an integer followed by a reduced fraction.
Note: The title comes from a relevant video.