It is wartime, and rationing is taking place in certain regions of your country. Your cities' region is one such region. The city chooses to give everyone the same amount, but in reality, larger people need more food. Chances are, a 200lb man is going to be eating more than that 7lb baby over there. The city, realizing that some people need more food, hires you, their best computer programmer, to solve the issue. They want you to write a program that will divvy up the food appropriately.
Being a smart programmer, you have developed a formula that gives an approximation of how much someone will eat based on their weight.
EAT = (WEIGHT - 1) / 20 + 1
For example, a 124 pound man will eat 7.125 units of food. Knowing that the food is served in packages of 1, and it would be irrational to cut them up, you can round the food units.
Each day, every person eats that many food units. If somebody goes for five days straight with less than that much food per day, they die of starvation.
You will receive population data in this form: Population*Weight
, so if you receive 700*180
, you know that their are 700 180lb men in the city. Your city has 100,000 units of food stored away.
For every day your city goes without anyone dying, you get one point. Whoever has the most points wins. Make sure you output how many days your city lasted before someone died.
Here is the input:
1000x90
2500x80
3000x150
2500x200
Edit: So, the rule "For every day your city goes without anyone dying, you get one point" was terribly abused. Rule change here: if anybody dies, then game over. No more counting.
x
or*
or up to us? Any restrictions on the kind of input? Does it have to be from stdin or could it be a function argument? Does it have to be a\n
delimited string or could it be an array of strings? What rounding should we use? And what's the output? Just the number of days? Or instructions on how to distribute food each day? Also some simple solved test cases might be useful... \$\endgroup\$70550
units assuming "normal" rounding. The next 4 days no one will starve, but on day 10 I don't have another70550
units to avoid someone dying. So 9 days is the maximum. Please correct me if I'm wrong. \$\endgroup\$