Share your insights or perspective on the financial matter presented in the input.

Shared groceries expenses between roommates to be divided as per specific consumption ratio and attendance
I asked how often grocery purchases are made in a comment, but I'm going to assume weekly for simplicity. If a roommate is present during the week following a grocery purchase, then they owe a share according to their preferences as you outlined them above. You will have to track the grocery cost by category for that week and calculate the balance owed by the person for that week. If there is a partial week where most expect to leave for a holiday or otherwise, then fewer groceries should be purchased for that week, and the cost of shares will decrease accordingly. One need only indicate preferences once, and weekly attendance thereafter. The only issue remaining is to determine how to record shares. If a normal person consumes 3 shares of milk, and .5 shares of butter, and so on, you simply add up all of the milk shares for the week and divide the milk bill by those shares. Same with the butter. The downside of this method is that you have to predict consumption in advance, so you may instead calculate by consumption after the fact with a deposit paid by all to create the initial grocery supply which will be refunded when that person leaves the grocery purchase co-op, and shares are calculated by who participated in the week prior to the grocery purchase. This also allows for a mid-week refresh if any commodity incurs higher than expected consumption, with the mid-week bill being added to the end of week refresh trip.