Utilize your financial knowledge, give your answer or opinion to the input question or subject . Answer format is not limited.

Shared groceries expenses between roommates to be divided as per specific consumption ratio and attendance
For a personal finance forum, this is too complicated for sustained use and you should find a simpler solution. For a mathematical exercise, you are missing information required to do the split fairly.  You have to know who overlaps and when to know how to do the splits.   For an extreme example, take your dates given: Considering 100 days of calculation period,  If Roommate D was the only person present for the last 10 days, they should pay 100% of the grocery bill as they are the only one eating.   From your initial data set, you can't know who should be splitting the tab for any given day. To do this mathematically, you'd need:  But don't forget "In Theory, Theory works.  In Practice, Practice works." Good theory would say make a large, complicated spreadsheet as described above.   Good practice would be to split up the costs in a much, much simpler way.