There is a group of 15 people, living together for one week.
Different people paid some amount to buy food items, so they had expenditure of €163 as group. They eat breakfast and dinner everyday, but not everyone consumed each meal (for reasons like staying away). For ease, lets say the breakfast costs €7,40 per day and dinner costs €15,86 per day (this is €163 / 7).
I did some calculation and get the amount who has to pay an amount of X to whom. But there was also a donation of €125 to the group. How can I calculate this to the amounts, benefiting the persons which have consumed the most (a person who stayed only one night sould get ledd than one who stayed 6 nights).
I tried to visualize and calculate in a Google Spreadsheet for later usage, but I failed. My logic is wrong. What did I miss, which way would you go?
Let $x_i$ be the number of nights stayed by the person $i$.Let the number of persons be $n$. You want that $$\text{Amount given to person }i\propto x_i$$
Let $c$ be a non zero constant. Let $cx_i$ be the amount given to the person $i$. Let the total amount be $P$.
Then, $$\sum_{i=1}^ncx_i=P$$ $$c\sum_{i=1}^nx_i=P$$ $$c=\frac{P}{\sum_{i=1}^nx_i}$$
Knowing $c$, you can find the amount for each person $i$.