# Apples going bad in the fridge

I read that some people got asked the following question during a job interview:

Let's say there are 10 apples in the fridge and all of them will go bad at the same speed. If you are only able to have one apple per day, which of the apples would you eat in each day?

There were no answers to this question. My personal logic and answer is that: it makes no difference. Is there a different logic behind it that I am missing or am I on the right path?

• It does not matter: apples do not spoil in 10 days. – Matsmath Sep 17 '16 at 20:55
• Unless you bought them in different days it shouldn't matter. Otherwise you should eat the oldest one. I guess... – FrodCube Sep 17 '16 at 21:09
• "all of them will go bad at the same speed" <--- this part is a bit unclear. If they go bad at the same speed, what's the rate of the speed? For example, is it an apple per day, per 2 hours, per whatever it is, etc? – Buffer Over Read Sep 17 '16 at 22:36

Executive summary, based on a comment posted by @ffao elsewhere:

This was a job-related question, and you were asked to recognize the assignment problem, which is a well-known combinatorial optimization problem.

The difficulty of this problem comes from the fancy term:

Option expiration: your apples at some time might rot beyond of any usefulness, when it is better to throw them away, than to try eating them.

Here is a mathematical model for this puzzle.

You have apples A1, A2, ..., A10. There is a nonnegative function v(X,t), measuring the nutrition contents of the apple X at time t. Since the nutrition content of the apples decay at the same rate, v(X,t)=v(X)-D(t), where D(t) is the amount of lost nutrition during t days, and v(X):=v(X,0) is just the nutrition content of your apples at the beginning.

Let's start with two apples so that to see what is going on. The apples worth v(A1), and v(A2). On day t this value decays by D(t), so the next day your apples in the fridge would worth v(A1)-D(1), v(A2)-D(1). After two days, the total value you consumed is v(A1)+(v(A2)-D(1)) or v(A2)+(v(A1)-D(1)), so v(A1)+v(A2)-D(1), irrespectively of what order you have eaten the apples. The caveat is that if at some point v(Ai)-D(1)<0, your apple expired worthless (a fancy term in quantitative analysis), at which point eating it would decrease the total amount of enjoyment, so you are better off just throwing it away.

Here are two examples, to compare: v(A1)=4, v(A2)=5, v(A3)=6, D(1)=1,D(2)=2. Each day the apples rot by decrement value of 1, so in three days you eat v(A1)+v(A2)+v(A3)-D(1)-D(2)=4+5+6-1-2=12 worth of nutritions.

On the other hand, imagine that v(A1)=4, v(A2)=5, v(A3)=6, D(1)=7. This means that on day 1 if you eat the oldest apple, you gain nutrition of 4, but the next day the two other apples will have nutrition value v(A2)=-2 and v(A3)=-1, so it is better to eat the best apple on day one, gaining a total of 6 nutrition value.

Here is how you solve the general problem: If you have just a few apples, you can try all n! permutations of the order in which you might eat them. Otherwise you look up how to solve the assignment problem which asks for a maximal weighted matching in a bipartite graph.

I'm pretty sure the logic of the question is to find out what logic the answerer applies to the question, not to try to find out a right answer given by the question itself.

You might eat the oldest apple first, so as to eat more apples before they go bad. You might eat the freshest apple first, so as to get the most nutrition per apple. (It actually doesn't say whether the apples were purchased at the same time or not, so this is an assumption that isn't set in stone). You might eat the largest apple first, so that you get more apple-volume. you might eat the smallest apple first, since small (and wild, organic, etc) tends to go with flavorful and concentrated, or at least tender, in produce. You might eat the tastiest apple first - assuming tasty because, I dunno, preferred varieties, size, freshness, other qualifiers (like organic). You might eat the ripest apple first, or the shiniest, or the one closer to the front of the fridge. You might eat one apple-equivalent of apple pie or butter or jelly first, and leave regular apples to maybeso go bad afterwards (which might works out like eating apple-bits form all the apples in said concoction to the required one-apple-volume).

Because, all the question tells you about the apples is they go bad at the same rate. You have ten, and can only eat one per day. That's it, that's all - the idea that because nothing more is said about the apples means there is no difference between them, is an assumption you can make...or you can not-make. All factors that you might use to distinguish between the apples, is your own addition. And what assumptions you make, can be used to understand a little more about you and what kind of person you are. Like a glass half-empty or half-full, it just says a little about you - if you see no difference, if you're looking for loopholes, if you make the assumptions the question nudges you towards, if you ask extra questions, what kind of things you value, how seriously you are thinking about it, how you react to a question with no clear cut answer.